blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 410 | content_id stringlengths 40 40 | detected_licenses listlengths 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 listlengths 1 1 | author_id stringlengths 0 313 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c1f950feffab3383824e6eaf59cd3eb913497db5 | b8350c9e323314c5c16f55efb5ca8f32d84158a9 | /src/com/mx/certificacion/semanafinal/seis/TestInterface.java | 86abfd31fc6ea82fdcb5cecef2173b194d69e5ae | [] | no_license | oxcesare/finalCertificacion | d6af263f9e152924e0a4406e7cf84b5897b19d39 | ba3c989a58e17997312d75a9d544e28246f47fcc | refs/heads/master | 2020-11-25T14:23:36.694126 | 2020-04-15T22:19:30 | 2020-04-15T22:19:30 | 228,713,682 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 671 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mx.certificacion.semanafinal.seis;
import java.io.IOException;
import java.sql.SQLException;
/**
*
* @author Supaada-q214
*
* Los metodos sobreescitos no pueden lanzar
* SQLException,
*/
public class TestInterface implements I1,I2{
@Override
public void m1() throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
| [
"Supaada-q214@10.200.6.115"
] | Supaada-q214@10.200.6.115 |
3687c062710ec59f4e5764323000e73b79ff71ac | c166436eaa93eff9316b5e87b7568daff7eb6108 | /kissanijar/src/main/java/fi/neter/kissani/fb/AlbumsPage.java | 80b3629a7c2d96e5c91fb46c797f54922fd2145f | [] | no_license | keskival/kissani | da3c598d7154f181a4c60660086264ac8d84efa6 | bc4cbe1f258106d55cca2cd0af51e0c7211d0914 | refs/heads/master | 2020-05-20T12:22:23.388522 | 2013-08-03T19:08:54 | 2013-08-03T19:08:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 484 | java | package fi.neter.kissani.fb;
import java.util.List;
import com.google.api.client.util.Key;
public class AlbumsPage {
@Key
private Paging paging;
@Key
private List<Album> data;
public void setPaging(Paging paging) {
this.paging = paging;
}
public Paging getPaging() {
return paging;
}
public void setData(List<Album> data) {
this.data = data;
}
public List<Album> getData() {
return data;
}
}
| [
"tero.keski-valkama@neter.fi"
] | tero.keski-valkama@neter.fi |
05a1700cddaa8824e2ddea35ec0706336912dbcf | c4c0302cb1c8be8d356bf9873f3fe9bbc020550b | /app/src/main/java/com/bw/movie/wxapi/WXEntryActivity.java | 51e6451f244d80f1d247b106c3f61013ed559547 | [] | no_license | AndroidGxk/WDCinema | 376bf5ccfb4556343f452464b48222a96eb53aa4 | b72f7129aad7cbda2d51929b45b42f15ae8ddc95 | refs/heads/master | 2020-04-17T21:49:55.219392 | 2019-02-21T10:59:02 | 2019-02-21T10:59:02 | 166,968,674 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,132 | java | package com.bw.movie.wxapi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.bw.movie.activity.MainActivity;
import com.bw.movie.bean.LoginBean;
import com.bw.movie.bean.LoginSubBean;
import com.bw.movie.bean.Result;
import com.bw.movie.core.ResultInfe;
import com.bw.movie.core.utils.Constant;
import com.bw.movie.greendao.DaoMaster;
import com.bw.movie.greendao.DaoSession;
import com.bw.movie.greendao.LoginSubBeanDao;
import com.bw.movie.presenter.WXLoginPresenter;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.socialize.weixin.view.WXCallbackActivity;
/**
* 作者:古祥坤 on 2019/1/27 11:39
* 邮箱:1724959985@qq.com
*/
public class WXEntryActivity extends WXCallbackActivity implements IWXAPIEventHandler, ResultInfe {
private IWXAPI api;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
// 通过WXAPIFactory工厂,获取IWXAPI的实例
api = WXAPIFactory.createWXAPI(this, Constant.APP_ID, false);
api.handleIntent(this.getIntent(), this);
}
@Override
public void onReq(BaseReq baseReq) {
}
//应用请求微信的响应结果将通过onResp回调
@Override
public void onResp(BaseResp resp) {
if (resp.errCode == BaseResp.ErrCode.ERR_OK) {//用户同意
final String code = ((SendAuth.Resp) resp).code;
WXLoginPresenter wxLoginPresenter = new WXLoginPresenter(this);
wxLoginPresenter.request(code);
} else {
Log.e("LKing", "授权登录失败\n\n自动返回");
}
}
@Override
public void success(Object data) {
Result result = (Result) data;
LoginBean loginBean = (LoginBean) result.getResult();
LoginSubBean userInfo = loginBean.getUserInfo();
SharedPreferences wx = getSharedPreferences("WX", MODE_PRIVATE);
SharedPreferences.Editor edit = wx.edit();
edit.putString("name", userInfo.getNickName());
edit.commit();
DaoSession daoSession = DaoMaster.newDevSession(WXEntryActivity.this, LoginSubBeanDao.TABLENAME);
LoginSubBeanDao loginSubBeanDao = daoSession.getLoginSubBeanDao();
loginSubBeanDao.loadAll();
LoginSubBean loginSubBean = new LoginSubBean();
loginSubBean.setUserId(userInfo.getUserId());
loginSubBean.setHeadPic(userInfo.getHeadPic());
loginSubBean.setNickName(userInfo.getNickName());
loginSubBean.setStatu(1);
long l = loginSubBeanDao.insertOrReplace(loginSubBean);
Toast.makeText(this, "" + l, Toast.LENGTH_SHORT).show();
startActivity(new Intent(WXEntryActivity.this, MainActivity.class));
}
@Override
public void errors(Throwable throwable) {
}
}
| [
"44991107+AndroidGxk@users.noreply.github.com"
] | 44991107+AndroidGxk@users.noreply.github.com |
f3137bc49108c2b68af264ea10bcfa53ed6bcdb9 | 3a699a3f7d4c45a9d5b99dc02ce245a41bf9a4c7 | /ksql-engine/src/main/java/io/confluent/ksql/function/udf/structfieldextractor/FetchFieldFromStruct.java | 3e527ba05fc46e182108a1867601088eef0c4dfa | [
"Apache-2.0"
] | permissive | dhruvilshah3/ksql | ac63f2e8515e02fb90f04b62b8a9957d69784192 | 2695433c9b4798d754e7459245426f3d34acb911 | refs/heads/master | 2020-03-23T11:08:26.346527 | 2018-07-18T16:50:54 | 2018-07-18T16:50:54 | 141,485,731 | 0 | 0 | Apache-2.0 | 2018-07-18T20:19:24 | 2018-07-18T20:19:24 | null | UTF-8 | Java | false | false | 1,212 | java | /*
* Copyright 2018 Confluent Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package io.confluent.ksql.function.udf.structfieldextractor;
import io.confluent.ksql.function.FunctionUtil;
import org.apache.kafka.connect.data.Struct;
import io.confluent.ksql.function.udf.Kudf;
public class FetchFieldFromStruct implements Kudf {
public static final String FUNCTION_NAME = "FETCH_FIELD_FROM_STRUCT";
@Override
public Object evaluate(final Object... args) {
FunctionUtil.ensureCorrectArgs(FUNCTION_NAME, args, Struct.class, String.class);
if (args[0] == null) {
return null;
}
final Struct struct = (Struct) args[0];
return struct.get((String) args[1]);
}
} | [
"noreply@github.com"
] | dhruvilshah3.noreply@github.com |
30a095405cbeb0adf3c56efee1ed5a0e2d9708c3 | 2350db6c9f0f48a8af282059073ac2f9e7f2b0e6 | /app/src/main/java/com/cn/tfl/utils/Functions.java | b906d214d4c193bb978736b0639cc073845ef495 | [] | no_license | tflgithub/CommunicationFragment | 55b52273ebe07a9c5e712dea050824ea8b49e12a | c11c1bad7e2d99daa31894b8b90b540452b52830 | refs/heads/master | 2020-12-30T11:52:31.475207 | 2017-05-16T09:02:59 | 2017-05-16T09:02:59 | 91,434,093 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 9,384 | java | package com.cn.tfl.utils;
import android.os.Bundle;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Happiness on 2017/5/16.
*/
public class Functions {
private HashMap<String, FunctionNoParamAndResult> mFunctionNoParamAndResult;
private HashMap<String, FunctionWithParamNoResult> mFunctionWithParamNoResult;
private HashMap<String, FunctionNoParamWithResult> mFunctionNoParamWithResult;
private HashMap<String, FunctionWithParamAndResult> mFunctionWithParamAndResult;
public static abstract class Function {
public String mFunctionName;
public Function(String functionName) {
this.mFunctionName = functionName;
}
}
//无参无返回
public static abstract class FunctionNoParamAndResult extends Function {
public FunctionNoParamAndResult(String functionName) {
super(functionName);
}
public abstract void function();
}
//添加无参无返回方法
public Functions addFunction(FunctionNoParamAndResult function) {
if (function == null) {
return this;
}
if (mFunctionNoParamAndResult == null) {
mFunctionNoParamAndResult = new HashMap<>();
}
mFunctionNoParamAndResult.put(function.mFunctionName, function);
return this;
}
//根据函数名,回调无参无返回值的函数
public void invokeFunc(String funcName) throws FunctionException {
FunctionNoParamAndResult f = null;
if (mFunctionNoParamAndResult != null) {
f = mFunctionNoParamAndResult.get(funcName);
if (f != null) {
f.function();
}
}
if (f == null) {
throw new FunctionException("没有此函数");
}
}
//有参无返回
public static abstract class FunctionWithParamNoResult<Param> extends Function {
public FunctionWithParamNoResult(String functionName) {
super(functionName);
}
public abstract void function(Param param);
}
//添加有参无返回方法
public Functions addFunction(FunctionWithParamNoResult function) {
if (function == null) {
return this;
}
if (mFunctionWithParamNoResult == null) {
mFunctionWithParamNoResult = new HashMap<>();
}
mFunctionWithParamNoResult.put(function.mFunctionName, function);
return this;
}
//根据函数名,回调有参无返回值的函数
public <Param> void invokeFunc(String funcName, Param param) throws FunctionException {
FunctionWithParamNoResult f = null;
if (mFunctionWithParamNoResult != null) {
f = mFunctionWithParamNoResult.get(funcName);
if (f != null) {
f.function(param);
}
}
if (f == null) {
throw new FunctionException("没有此函数");
}
}
//无参有返回
public static abstract class FunctionNoParamWithResult<Result> extends Function {
public FunctionNoParamWithResult(String functionName) {
super(functionName);
}
public abstract Result function();
}
//添加无参有返回方法
public Functions addFunction(FunctionNoParamWithResult function) {
if (function == null) {
return this;
}
if (mFunctionNoParamWithResult == null) {
mFunctionNoParamWithResult = new HashMap<>();
}
mFunctionNoParamWithResult.put(function.mFunctionName, function);
return this;
}
//根据函数名,回调无参有返回值的函数
public <Result> Result invokeFunc(String funcName, Class<Result> c) throws FunctionException {
FunctionNoParamWithResult f = null;
if (mFunctionNoParamWithResult != null) {
f = mFunctionNoParamWithResult.get(funcName);
if (f != null) {
if (c != null) {
return c.cast(f.function());
} else {
return (Result) f.function();
}
}
}
if (f == null) {
throw new FunctionException("没有此函数");
}
return null;
}
//有参有返回
public static abstract class FunctionWithParamAndResult<Result, Param> extends Function {
public FunctionWithParamAndResult(String functionName) {
super(functionName);
}
public abstract Result function(Param param);
}
//添加有参有返回方法
public Functions addFunction(FunctionWithParamAndResult function) {
if (function == null) {
return this;
}
if (mFunctionWithParamAndResult == null) {
mFunctionWithParamAndResult = new HashMap<>();
}
mFunctionWithParamAndResult.put(function.mFunctionName, function);
return this;
}
//根据函数名,回调有参有返回值的函数
public <Result, Param> Result invokeFunc(String funcName, Class<Result> c, Param param) throws FunctionException {
FunctionWithParamAndResult f = null;
if (mFunctionWithParamAndResult != null) {
f = mFunctionWithParamAndResult.get(funcName);
if (f != null) {
if (c != null) {
return c.cast(f.function(param));
} else {
return (Result) f.function(param);
}
}
}
if (f == null) {
throw new FunctionException("没有此函数");
}
return null;
}
/**
* 函数的参数,当函数的参数涉及到多个值时,可以用此类,
* 此类使用规则:存参数与取参数的顺序必须一致,否则报错
*/
public static class FunctionParams {
private Bundle mParams = new Bundle(1);
private int mIndex = -1;
private Map mObjectParams = new HashMap(1);
FunctionParams(Bundle mParams, Map mObjectParams) {
this.mParams = mParams;
this.mObjectParams = mObjectParams;
}
public <Param> Param getObject(Class<Param> p) {
if (mObjectParams == null) {
return null;
}
return p.cast(mObjectParams.get((mIndex++) + ""));
}
/**
* 获取int值
*
* @return
*/
public int getInt() {
if (mParams != null) {
return mParams.getInt((mIndex++) + "");
}
return 0;
}
/**
* 获取int值
*
* @param defalut
* @return
*/
public int getInt(int defalut) {
if (mParams != null) {
return mParams.getInt((mIndex++) + "");
}
return defalut;
}
/**
* 获取字符串
*
* @param defalut
* @return
*/
public String getString(String defalut) {
if (mParams != null) {
return mParams.getString((mIndex++) + "");
}
return defalut;
}
/**
* 获取字符串
*
* @return
*/
public String getString() {
if (mParams != null) {
return mParams.getString((mIndex++) + "");
}
return null;
}
/**
* 获取Boolean值
*
* @return 默认返回false
*/
public boolean getBoolean() {
if (mParams != null) {
return mParams.getBoolean((mIndex++) + "");
}
return false;
}
/**
* 该类用来创建函数参数
*/
public static class FunctionParamsBuilder {
private Bundle mParams;
private int mIndex = -1;
private Map mObjectParams = new HashMap(1);
public FunctionParamsBuilder() {
}
public FunctionParamsBuilder putInt(int value) {
if (mParams == null) {
mParams = new Bundle(2);
}
mParams.putInt((mIndex++) + "", value);
return this;
}
public FunctionParamsBuilder putString(String value) {
if (mParams == null) {
mParams = new Bundle(2);
}
mParams.putString((mIndex++) + "", value);
return this;
}
public FunctionParamsBuilder putBoolean(boolean value) {
if (mParams == null) {
mParams = new Bundle(2);
}
mParams.putBoolean((mIndex++) + "", value);
return this;
}
public FunctionParamsBuilder putObject(Object value) {
if (mObjectParams == null) {
mObjectParams = new HashMap(1);
}
mObjectParams.put((mIndex++) + "", value);
return this;
}
public FunctionParams create() {
FunctionParams instance = new FunctionParams(mParams, mObjectParams);
return instance;
}
}
}
}
| [
"tangyoule@126.com"
] | tangyoule@126.com |
0ec09f299ee27c810a01ef4c4a95304529b9c14a | 9f3addecde0443f78c1531221f9617dd94ae7790 | /src/com/company/Color.java | ee804cfaed3e81e637e48b14cf7abac5efb9364a | [] | no_license | rahulkumaryadav/Java-DesignPattern-Bridge | 4e66980f81c6d3315c89bfa8e86d79c689733880 | eb852777dec34b7c8dba6b35779d5ce1876961cc | refs/heads/master | 2020-04-09T12:05:12.733319 | 2019-03-09T08:17:19 | 2019-03-09T08:17:19 | 160,335,117 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 79 | java | package com.company;
public interface Color {
public void applyColor();
}
| [
"rahulkumar96369@gmail.com"
] | rahulkumar96369@gmail.com |
78a7200ae3b11323875a1b32d01cc22c8b32748b | 5df80a6c6569a46646da8c64dea07152a75f4b1a | /多线程/20201223/src/com/mystudy/volatilekw/Test02.java | ec2c379a9c21d12a49e568f0688416182cbef035 | [] | no_license | nanguling/thread | d187bb75ca3ae0e2a4c6ba36895455aa21d6f146 | cde732eb3bc44c61be8f7569ca73343cc17506ff | refs/heads/master | 2023-02-16T09:53:04.267602 | 2021-01-17T09:22:50 | 2021-01-17T09:22:50 | 323,375,821 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,466 | java | package com.mystudy.volatilekw;
public class Test02 {
public static void main(String[] args) throws InterruptedException {
PrintString ps = new PrintString();
//创建一个子线程
new Thread(new Runnable() {
@Override
public void run() {
try {
ps.printStringMethod();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
Thread.sleep(1000);
System.out.println("mian线程改变打印标志");
ps.setContinuePrint(false);
//程序运行后可能会出现死循环的情况
//原因:main线程修改了打印标志,子线程读取不到
//解决:使用volatile关键字来修饰打印标志
// volatile可以强制线程从公共内存中读取变量的值,而不是从工作内存中读取
}
//定义类打印字符串
static class PrintString{
private volatile boolean continuePrint = true;
public void setContinuePrint(boolean continuePrint) {
this.continuePrint = continuePrint;
}
public void printStringMethod() throws InterruptedException {
System.out.println("子线程开始打印。。。。");
while (continuePrint) {
}
System.out.println("子线程结束打印。。。。");
}
}
}
| [
"814846779@qq.com"
] | 814846779@qq.com |
58f3776c7fd9a013914cef842cfc8e69edfe89e2 | 05e0e9cd84a00309469b360bf9ad59e9ebf0e194 | /src/main/java/me/kyllian/headshot/listeners/EntityShootBowListener.java | d3ab2be1834e8f75c165e8aee3d239ac6aff4814 | [] | no_license | InstantlyMoist/HeadShot | b342f8f4f7a4024e60e4019d560a623064dfa63a | 421e42b70050eb00b5bc6386d7e57cf16a7bc309 | refs/heads/master | 2020-04-14T13:45:40.529941 | 2019-04-13T13:46:01 | 2019-04-13T13:46:01 | 163,878,155 | 2 | 3 | null | 2020-03-20T05:41:56 | 2019-01-02T18:55:07 | Java | UTF-8 | Java | false | false | 906 | java | package me.kyllian.headshot.listeners;
import me.kyllian.headshot.HeadShotPlugin;
import me.kyllian.headshot.utils.MessageUtils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;
public class EntityShootBowListener implements Listener {
private HeadShotPlugin plugin;
public EntityShootBowListener(HeadShotPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onEntityShootBow(EntityShootBowEvent event) {
if (!plugin.isEnchantmentEnabled()) plugin.allowedArrows.add(event.getProjectile().getUniqueId());
if (event.getBow().getItemMeta().hasLore() && event.getBow().getItemMeta().getLore().contains(MessageUtils.colorTranslate(plugin.getHeadShotEnchant().getDisplayName()))) {
plugin.allowedArrows.add(event.getProjectile().getUniqueId());
}
}
}
| [
"32609460+InstantlyMoist@users.noreply.github.com"
] | 32609460+InstantlyMoist@users.noreply.github.com |
363af63fcc731be3d1d213c2f1bb5c2f34ade35b | 2604238618db8886d8fc8f24a11a1033372dd7c6 | /projects/assessments/Maven.Assessment1.0/src/test/java/com/zipcodewilmington/assessment1/part2/MultiplesDeleterTest.java | cc204f2bcef5fd71964caf6216dff12a5b7f5f5c | [] | no_license | CodeDifferently/interview-prep | 59c23dac2d0a076e50d7caeabf0cb509de89e7f8 | e408a89ef5be33d150b95896737cf6c745498490 | refs/heads/master | 2022-12-09T10:56:38.727701 | 2019-09-25T19:29:53 | 2019-09-25T19:29:53 | 206,587,185 | 0 | 1 | null | 2022-12-09T00:41:04 | 2019-09-05T14:43:29 | Java | UTF-8 | Java | false | false | 1,724 | java | package com.zipcodewilmington.assessment1.part2;
import com.zipcodewilmington.assessment1.UnitTestingUtils;
import org.junit.Before;
import org.junit.Test;
/**
* Created by leon on 2/16/18.
*/
public class MultiplesDeleterTest {
@Test
public void deleteEvensTest() {
// Given
Integer[] inputArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
Integer[] expected = { 1, 3, 5, 7, 9 };
// When
Integer[] actual = MultiplesDeleter.deleteEvens(inputArray);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
@Test
public void deleteOddsTest() {
// Given
Integer[] inputArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
Integer[] expected = { 2, 4, 6, 8, 10 };
// When
Integer[] actual = MultiplesDeleter.deleteOdds(inputArray);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
@Test
public void deleteMultiplesOf3Test() {
// Given
Integer[] inputArray = { 3, 6, 9, 12, 15, 4, 7, 10, 13, 16};
Integer[] expected = {4, 7, 10, 13, 16};
// When
Integer[] actual = MultiplesDeleter.deleteMultiplesOf3(inputArray);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
@Test
public void deleteMultiplesOfNTest() {
// Given
Integer multiple = 6;
Integer[] inputArray = { 6, 12, 18, 24, 30, 4, 7, 10, 13, 16};
Integer[] expected = {4, 7, 10, 13, 16};
// When
Integer[] actual = MultiplesDeleter.deleteMultiplesOfN(inputArray, multiple);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
}
| [
"leonhunter@Leons-MacBook-Pro-2.local"
] | leonhunter@Leons-MacBook-Pro-2.local |
952ae9b0405826c77d89360b7090ef480c1a9c8c | 090aec651f45048fcd679566efbc807f4661fda3 | /rings/src/main/java/cc/redberry/rings/poly/QuotientRing.java | 4030c41c408890425a160c53fb7383064fd09d3b | [
"Apache-2.0",
"Apache-1.1"
] | permissive | nixworks/rings | 44446db3ca87af509d1528080dce50bf238cec2f | 5e1b4502037aedd7121af6248a1c4993a40fec2e | refs/heads/master | 2021-04-16T01:51:15.062570 | 2018-03-01T14:24:43 | 2018-03-01T14:35:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,941 | java | package cc.redberry.rings.poly;
import cc.redberry.rings.AQuotientRing;
import cc.redberry.rings.WithVariables;
import cc.redberry.rings.poly.multivar.AMonomial;
import cc.redberry.rings.poly.multivar.AMultivariatePolynomial;
import cc.redberry.rings.poly.multivar.Ideal;
/**
* Multivariate quotient ring
*/
public class QuotientRing<Term extends AMonomial<Term>, Poly extends AMultivariatePolynomial<Term, Poly>>
extends AQuotientRing<Poly> implements IPolynomialRing<Poly> {
/** the ideal */
public final Ideal<Term, Poly> ideal;
private final Poly factory;
public QuotientRing(IPolynomialRing<Poly> baseRing, Ideal<Term, Poly> ideal) {
// fixme polys over Z ????
super(baseRing);
this.ideal = ideal;
this.factory = ideal.getBasisGenerator(0).createZero();
}
@Override
public Poly mod(Poly el) {
return ideal.normalForm(el);
}
@Override
public int nVariables() {
return factory.nVariables;
}
@Override
public Poly factory() {
return factory;
}
@Override
public Poly parse(String string) {
return parse(string, WithVariables.defaultVars(nVariables()));
}
@Override
public Poly parse(String string, String[] variables) {
return valueOf(factory.parsePoly(string, variables));
}
@Override
public Poly variable(int variable) {
return factory.createMonomial(variable, 1);
}
@Override
public String toString(String[] variables) {
return toString(factory.coefficientRingToString(), variables);
}
@Override
public String toString(String coefficientDomain, String[] variables) {
return ((IPolynomialRing) baseRing).toString(coefficientDomain, variables) + "/" + ideal.toString(variables) + "";
}
@Override
public String toString() {
return toString(WithVariables.defaultVars(nVariables()));
}
}
| [
"stvlpos@mail.ru"
] | stvlpos@mail.ru |
40c0a64105350f5a8ecb385ffae0996d269e361f | 1b307344a0dd5590e204529b7cc7557bed02d2b9 | /sdk/storagecache/azure-resourcemanager-storagecache/src/test/java/com/azure/resourcemanager/storagecache/generated/StorageTargetResourceTests.java | 9be073add9040a90302ae233ab9714854e7d7430 | [
"LGPL-2.1-or-later",
"BSD-3-Clause",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference",
"CC0-1.0",
"LicenseRef-scancode-generic-cla"
] | permissive | alzimmermsft/azure-sdk-for-java | 7e72a194e488dd441e44e1fd12c0d4c1cacb1726 | 9f5c9b2fd43c2f9f74c4f79d386ae00600dd1bf4 | refs/heads/main | 2023-09-01T00:13:48.628043 | 2023-03-27T09:00:31 | 2023-03-27T09:00:31 | 176,596,152 | 4 | 0 | MIT | 2023-03-08T18:13:24 | 2019-03-19T20:49:38 | Java | UTF-8 | Java | false | false | 951 | java | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.storagecache.generated;
import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagecache.models.StorageTargetResource;
public final class StorageTargetResourceTests {
@org.junit.jupiter.api.Test
public void testDeserialize() throws Exception {
StorageTargetResource model =
BinaryData
.fromString("{\"location\":\"aboekqv\",\"id\":\"lns\",\"name\":\"vbxwyjsflhh\",\"type\":\"aalnjixi\"}")
.toObject(StorageTargetResource.class);
}
@org.junit.jupiter.api.Test
public void testSerialize() throws Exception {
StorageTargetResource model = new StorageTargetResource();
model = BinaryData.fromObject(model).toObject(StorageTargetResource.class);
}
}
| [
"noreply@github.com"
] | alzimmermsft.noreply@github.com |
2437115684fb6ba03418910981f82e7070f06225 | 7f98ed4dbc17c01fc91f6e8edb114d68b9baaba9 | /src/main/java/com/dao/objects/Mp3.java | 5d8045b2bbee9ab70430c1171c3c3c876f7a766b | [] | no_license | h5dde45/Spring_15_02_18 | e6ed4d9bd8998abe9a0b1061c3d0f680075c4896 | e2dfcbce7651e5dfbd18cfc29662e27c564f8a23 | refs/heads/master | 2021-04-29T21:13:25.431134 | 2018-02-18T15:16:58 | 2018-02-18T15:16:58 | 121,610,307 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 711 | java | package com.dao.objects;
public class Mp3 {
private int id;
private String name;
private Author author;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Author getAuthor() {
return author;
}
public void setAuthor(Author author) {
this.author = author;
}
@Override
public String toString() {
return "Mp3{" +
"id=" + id +
", name='" + name + '\'' +
", author=" + author +
'}';
}
}
| [
"tmvf@yandex.ru"
] | tmvf@yandex.ru |
c7255d36119051ed5b8bb68de1af6103895e4611 | 025775165170bf5163f2f251f8ddc23c73895134 | /src/Utils/IntegerUtils.java | 109c379826e6abf2487e4bd992e99d9bbbcf20c2 | [] | no_license | Wild-Track/Java-Project | 9e9baad826cf4b91a7e1f44f61dd3ed845b4b442 | 070abc3ac3ec90391224093ba8631ab6a53b11be | refs/heads/master | 2022-11-09T02:00:43.972643 | 2020-06-19T10:16:10 | 2020-06-19T10:16:10 | 272,162,663 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 481 | java | package Utils;
public class IntegerUtils {
public static boolean isEmpty(final CharSequence cs) {
return cs == null || cs.length() == 0;
}
public static boolean isNumeric(final CharSequence cs) {
if (isEmpty(cs)) {
return false;
}
final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (!Character.isDigit(cs.charAt(i))) {
return false;
}
}
return true;
}
} | [
"Wildryx@outlook.fr"
] | Wildryx@outlook.fr |
de28eddfd783c70a56f70ff0b500710d8f815d52 | 83e81c25b1f74f88ed0f723afc5d3f83e7d05da8 | /packages/BackupEncryption/test/robolectric/src/com/android/server/testing/shadows/ShadowBackupDataInput.java | f7d4842714750c9d293b0f1f9830d8393d569b3a | [
"Apache-2.0",
"LicenseRef-scancode-unicode"
] | permissive | Ankits-lab/frameworks_base | 8a63f39a79965c87a84e80550926327dcafb40b7 | 150a9240e5a11cd5ebc9bb0832ce30e9c23f376a | refs/heads/main | 2023-02-06T03:57:44.893590 | 2020-11-14T09:13:40 | 2020-11-14T09:13:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,501 | java | /*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.testing.shadows;
import static com.google.common.base.Preconditions.checkState;
import android.annotation.Nullable;
import android.app.backup.BackupDataInput;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import java.io.ByteArrayInputStream;
import java.io.FileDescriptor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/** Shadow for BackupDataInput. */
@Implements(BackupDataInput.class)
public class ShadowBackupDataInput {
private static final List<DataEntity> ENTITIES = new ArrayList<>();
@Nullable private static IOException sReadNextHeaderException;
@Nullable private ByteArrayInputStream mCurrentEntityInputStream;
private int mCurrentEntity = -1;
/** Resets the shadow, clearing any entities or exception. */
public static void reset() {
ENTITIES.clear();
sReadNextHeaderException = null;
}
/** Sets the exception which the input will throw for any call to {@link #readNextHeader}. */
public static void setReadNextHeaderException(@Nullable IOException readNextHeaderException) {
ShadowBackupDataInput.sReadNextHeaderException = readNextHeaderException;
}
/** Adds the given entity to the input. */
public static void addEntity(DataEntity e) {
ENTITIES.add(e);
}
/** Adds an entity to the input with the given key and value. */
public static void addEntity(String key, byte[] value) {
ENTITIES.add(new DataEntity(key, value, value.length));
}
public void __constructor__(FileDescriptor fd) {}
@Implementation
public boolean readNextHeader() throws IOException {
if (sReadNextHeaderException != null) {
throw sReadNextHeaderException;
}
mCurrentEntity++;
if (mCurrentEntity >= ENTITIES.size()) {
return false;
}
byte[] value = ENTITIES.get(mCurrentEntity).mValue;
if (value == null) {
mCurrentEntityInputStream = new ByteArrayInputStream(new byte[0]);
} else {
mCurrentEntityInputStream = new ByteArrayInputStream(value);
}
return true;
}
@Implementation
public String getKey() {
return ENTITIES.get(mCurrentEntity).mKey;
}
@Implementation
public int getDataSize() {
return ENTITIES.get(mCurrentEntity).mSize;
}
@Implementation
public void skipEntityData() {
// Do nothing.
}
@Implementation
public int readEntityData(byte[] data, int offset, int size) {
checkState(mCurrentEntityInputStream != null, "Must call readNextHeader() first");
return mCurrentEntityInputStream.read(data, offset, size);
}
}
| [
"keneankit01@gmail.com"
] | keneankit01@gmail.com |
77ec09b3bda16adaf4d3916e1a7bcae67512b5b2 | 56a4d1be3c6b82f4e3fad5506821dbe16194ba44 | /src/main/java/com/dmarcini/app/resources/NegativeAmountException.java | a9004b023cf1371315805735147b39381105b08f | [
"MIT"
] | permissive | dmarcini/blockchain | 8c9b35c284c8cfabcf0441d9262eb4ee4c5ba3b5 | fad48a4e4f378e0f82d5989a8ed418184f2144f4 | refs/heads/master | 2022-11-28T16:12:11.346367 | 2020-07-29T16:48:10 | 2020-08-04T16:34:17 | 281,038,094 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 195 | java | package com.dmarcini.app.resources;
public final class NegativeAmountException extends Exception {
public NegativeAmountException(String errorMessage) {
super(errorMessage);
}
}
| [
"damian.marciniak.1996@gmail.com"
] | damian.marciniak.1996@gmail.com |
18ec0ecbddfb1e6bf1ab63249cdc766a62ac3115 | 7bede337c806cd70d9cf1b21f6f6b512ae3a6437 | /lib/src/main/java/com/android/lib/view/line/view/VerticalDashView.java | 0cd72db15b394ca936d1a0562fcf55e67dee5dda | [] | no_license | summernecro/ALib | ce607b600dc3fad511cc8f5270ae102b3580fe5b | ee7c9d8c15f968716d8fda7707decbf818d27435 | refs/heads/master | 2020-03-12T19:14:15.242483 | 2019-02-12T01:33:06 | 2019-02-12T01:33:06 | 130,780,564 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,733 | java | package com.android.lib.view.line.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import com.android.lib.R;
import com.android.lib.util.LogUtil;
/**
* Created by ${viwmox} on 2016-06-02.
*/
public class VerticalDashView extends View {
int dashColor;
float dashGap;
float dashWidth;
int bgcolor;
float w;
Paint paint = new Paint();
public VerticalDashView(Context context) {
super(context);
}
public VerticalDashView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.DashView);
dashColor = typedArray.getColor(R.styleable.DashView_dashcolor, Color.BLACK);
dashGap = typedArray.getDimension(R.styleable.DashView_dashgap, 10f);
dashWidth = typedArray.getDimension(R.styleable.DashView_hashwidth, 10f);
bgcolor = typedArray.getColor(R.styleable.DashView_dashbg, Color.WHITE);
w = typedArray.getDimension(R.styleable.DashView_w, 10f);
paint.setColor(dashColor);
paint.setStyle(Paint.Style.FILL);
}
@Override
protected void onDraw(Canvas canvas) {
paint.setStrokeWidth(getHeight());
paint.setColor(dashColor);
for (int i = 0; i < getHeight() / (dashGap + dashWidth); i++) {
canvas.drawRect(0, 0 + (dashGap + dashWidth) * i, w, dashWidth + (dashGap + dashWidth) * i, paint);
}
}
}
| [
"summernecro@gmail.com"
] | summernecro@gmail.com |
d98a55a1422fc8b5c5dd3f8c9a7885956825e6fe | ebdcaff90c72bf9bb7871574b25602ec22e45c35 | /modules/adwords_appengine/src/main/java/com/google/api/ads/adwords/jaxws/v201809/cm/ImageError.java | dab7dd7c10740b5c66eff50a70898d45ae8e7ace | [
"Apache-2.0"
] | permissive | ColleenKeegan/googleads-java-lib | 3c25ea93740b3abceb52bb0534aff66388d8abd1 | 3d38daadf66e5d9c3db220559f099fd5c5b19e70 | refs/heads/master | 2023-04-06T16:16:51.690975 | 2018-11-15T20:50:26 | 2018-11-15T20:50:26 | 158,986,306 | 1 | 0 | Apache-2.0 | 2023-04-04T01:42:56 | 2018-11-25T00:56:39 | Java | UTF-8 | Java | false | false | 2,224 | java | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.api.ads.adwords.jaxws.v201809.cm;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
/**
*
* Error class for errors associated with parsing image data.
*
*
* <p>Java class for ImageError complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="ImageError">
* <complexContent>
* <extension base="{https://adwords.google.com/api/adwords/cm/v201809}ApiError">
* <sequence>
* <element name="reason" type="{https://adwords.google.com/api/adwords/cm/v201809}ImageError.Reason" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ImageError", propOrder = {
"reason"
})
public class ImageError
extends ApiError
{
@XmlSchemaType(name = "string")
protected ImageErrorReason reason;
/**
* Gets the value of the reason property.
*
* @return
* possible object is
* {@link ImageErrorReason }
*
*/
public ImageErrorReason getReason() {
return reason;
}
/**
* Sets the value of the reason property.
*
* @param value
* allowed object is
* {@link ImageErrorReason }
*
*/
public void setReason(ImageErrorReason value) {
this.reason = value;
}
}
| [
"jradcliff@users.noreply.github.com"
] | jradcliff@users.noreply.github.com |
acc12002560547d216c0bfbb891142904f35f240 | cca4d63107dad4c88eda7dd70e13d5b8685e7485 | /src/main/java/browniepoints/model/helper/UserHelper.java | 92f3086142f1c662012f57fb6c47fc15a2f6174e | [] | no_license | rajpaulie/browniepoints | 7632d5c86b612d86f48fda5fe6fab39ce0def3c4 | 41a9a9bbee86f563959a3337c21ceea033d33efe | refs/heads/master | 2021-01-25T12:24:18.892906 | 2013-07-14T07:12:03 | 2013-07-14T07:12:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,867 | java | package main.java.browniepoints.model.helper;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import main.java.browniepoints.model.User;
public class UserHelper implements SQLConverter {
private static Connection conn = ConnectionProvider.getConnection();
private static final UserHelper instance = new UserHelper();
private Integer loggedInUid = null;
public Integer getLoggedInUid() {
return loggedInUid;
}
public void setLoggedInUid(Integer loggedInUid) {
System.out.println("Setting uid to " + loggedInUid);
this.loggedInUid = loggedInUid;
}
private static final String INSERT_SQL = "insert into public.\"user\" "
+ "(email, name, points, phone) values (?, ?, ?, ?)";
private static final String SELECT_SQL = "select uid, email, name, points, phone "
+ "from public.\"user\"";
private static final String UPDATE_SQL = "update public.\"user\" "
+ "set email = ?, name = ?, points = ?, phone = ? where uid = ?";
Map<Integer, User> userByUID = new HashMap<Integer, User>();
Map<String, User> userByEmail = new HashMap<String, User>();
private UserHelper() {
init();
}
public static UserHelper getInstance() {
return instance;
}
private void init() {
if (null == conn) {
conn = ConnectionProvider.getConnection();
}
List<User> users = select();
userByEmail.clear();
userByUID.clear();
for (Integer i = 0; i < users.size(); ++i) {
userByEmail.put(users.get(i).getEmail(), users.get(i));
userByUID.put(users.get(i).getUid(), users.get(i));
}
}
public List<?> convertRSToList(ResultSet rs) {
List<User> userList = new ArrayList<User>();
if (rs == null) return userList;
try {
while (rs.next()) {
Integer uid = rs.getInt("uid");
String email = rs.getString("email");
String name = rs.getString("name");
Integer points = rs.getInt("points");
String phone = rs.getString("phone");
userList.add(new User(uid, email, name, points, phone));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return userList;
}
public void setColumnsForUpdate(Object entity, PreparedStatement stmt) {
if (stmt == null || entity == null) return;
User user = (User) entity;
try {
stmt.setString(1, user.getEmail());
stmt.setString(2, user.getName());
stmt.setInt(3, user.getPoints());
stmt.setString(4, user.getPhone());
if (user.hasUid()) stmt.setInt(5, user.getUid());
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void insert(User user) {
QueryHelper.ExecuteInsertOrUpdate(conn, INSERT_SQL, user, this);
// update cache
init();
}
public void update(User user) {
QueryHelper.ExecuteInsertOrUpdate(conn, UPDATE_SQL, user, this);
// update cache
init();
}
public List<User> select() {
return (List<User>) QueryHelper.ExecuteSelect(conn, SELECT_SQL, this);
}
public User getUser(Integer id) {
return userByUID.get(id);
}
public User getUser(String email) {
return userByEmail.get(email);
}
@Override
protected void finalize() throws Throwable {
// TODO Auto-generated method stub
super.finalize();
conn.close();
}
public static void main(String[] args) {
User user = new User("paul.rahul@gmail.com", "Rahul Paul", 0, "12345");
UserHelper helper = new UserHelper();
helper.insert(user);
List<User> users = helper.select();
String email = "";
for (Integer i = 0; i < users.size(); ++i) {
email = users.get(i).getEmail();
System.out.println(email);
}
User nu = helper.getUser(email);
System.out.println(nu.getUid());
nu.setEmail("raj@gmail.com");
helper.update(nu);
}
} | [
"rahul@rahul-VirtualBox.(none)"
] | rahul@rahul-VirtualBox.(none) |
93fee9d9af0a349f460754b5683460d893612c20 | 9d57c18e12712f72ebd5250638b97060adf85d85 | /Software/es.unican.moses.sle.db.eer2sql.diagram/src/EER/diagram/edit/helpers/AggregationEditHelper.java | 351d89af8bcd2e9950a79b4712f6a11cd7984c65 | [] | no_license | latacita/unicaneer2sql | 793184fbb2ec0cd46be3346688371e7475b32be6 | ee7bdc752d05d7092b1613c788a28ec749ee49c4 | refs/heads/master | 2016-09-08T16:06:47.029233 | 2011-09-06T07:25:47 | 2011-09-06T07:25:47 | 32,793,275 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package EER.diagram.edit.helpers;
/**
* @generated
*/
public class AggregationEditHelper extends EERmodelBaseEditHelper {
}
| [
"adof13@3cf175a4-71be-ec21-8e38-539ed72d85be"
] | adof13@3cf175a4-71be-ec21-8e38-539ed72d85be |
e20be34cc52f391226f725c2734a9133c782590e | 9254e7279570ac8ef687c416a79bb472146e9b35 | /facebody-20200910/src/main/java/com/aliyun/facebody20200910/Client.java | 4a757dbd785ddcdf6d7939f99bfb8f170d7c9822 | [
"Apache-2.0"
] | permissive | lquterqtd/alibabacloud-java-sdk | 3eaa17276dd28004dae6f87e763e13eb90c30032 | 3e5dca8c36398469e10cdaaa34c314ae0bb640b4 | refs/heads/master | 2023-08-12T13:56:26.379027 | 2021-10-19T07:22:15 | 2021-10-19T07:22:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,863 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.facebody20200910;
import com.aliyun.tea.*;
import com.aliyun.facebody20200910.models.*;
import com.aliyun.teautil.*;
import com.aliyun.teautil.models.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;
import com.aliyun.openapiutil.*;
import com.aliyun.endpointutil.*;
public class Client extends com.aliyun.teaopenapi.Client {
public Client(Config config) throws Exception {
super(config);
this._endpointRule = "regional";
this.checkConfig(config);
this._endpoint = this.getEndpoint("facebody", _regionId, _endpointRule, _network, _suffix, _endpointMap, _endpoint);
}
public String getEndpoint(String productId, String regionId, String endpointRule, String network, String suffix, java.util.Map<String, String> endpointMap, String endpoint) throws Exception {
if (!com.aliyun.teautil.Common.empty(endpoint)) {
return endpoint;
}
if (!com.aliyun.teautil.Common.isUnset(endpointMap) && !com.aliyun.teautil.Common.empty(endpointMap.get(regionId))) {
return endpointMap.get(regionId);
}
return com.aliyun.endpointutil.Client.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
/**
* 行人检测快速版
*/
public DetectIPCPedestrianOptimizedResponse detectIPCPedestrianOptimized(DetectIPCPedestrianOptimizedRequest request) throws Exception {
RuntimeOptions runtime = new RuntimeOptions();
java.util.Map<String, String> headers = new java.util.HashMap<>();
return this.detectIPCPedestrianOptimizedWithOptions(request, headers, runtime);
}
public DetectIPCPedestrianOptimizedResponse detectIPCPedestrianOptimizedWithOptions(DetectIPCPedestrianOptimizedRequest request, java.util.Map<String, String> headers, RuntimeOptions runtime) throws Exception {
com.aliyun.teautil.Common.validateModel(request);
java.util.Map<String, Object> body = new java.util.HashMap<>();
if (!com.aliyun.teautil.Common.isUnset(request.imageData)) {
body.put("imageData", request.imageData);
}
if (!com.aliyun.teautil.Common.isUnset(request.width)) {
body.put("width", request.width);
}
if (!com.aliyun.teautil.Common.isUnset(request.height)) {
body.put("height", request.height);
}
OpenApiRequest req = OpenApiRequest.build(TeaConverter.buildMap(
new TeaPair("headers", headers),
new TeaPair("body", com.aliyun.openapiutil.Client.parseToMap(body))
));
return TeaModel.toModel(this.doROARequestWithForm("DetectIPCPedestrianOptimized", "2020-09-10", "HTTPS", "POST", "AK", "/viapi/k8s/facebody/detect-ipc-pedestrian-optimized", "json", req, runtime), new DetectIPCPedestrianOptimizedResponse());
}
public ExecuteServerSideVerificationResponse executeServerSideVerification(ExecuteServerSideVerificationRequest request) throws Exception {
RuntimeOptions runtime = new RuntimeOptions();
java.util.Map<String, String> headers = new java.util.HashMap<>();
return this.executeServerSideVerificationWithOptions(request, headers, runtime);
}
public ExecuteServerSideVerificationResponse executeServerSideVerificationWithOptions(ExecuteServerSideVerificationRequest request, java.util.Map<String, String> headers, RuntimeOptions runtime) throws Exception {
com.aliyun.teautil.Common.validateModel(request);
java.util.Map<String, Object> body = new java.util.HashMap<>();
if (!com.aliyun.teautil.Common.isUnset(request.certificateName)) {
body.put("certificateName", request.certificateName);
}
if (!com.aliyun.teautil.Common.isUnset(request.certificateNumber)) {
body.put("certificateNumber", request.certificateNumber);
}
if (!com.aliyun.teautil.Common.isUnset(request.facialPictureData)) {
body.put("facialPictureData", request.facialPictureData);
}
if (!com.aliyun.teautil.Common.isUnset(request.facialPictureUrl)) {
body.put("facialPictureUrl", request.facialPictureUrl);
}
if (!com.aliyun.teautil.Common.isUnset(request.sceneType)) {
body.put("sceneType", request.sceneType);
}
OpenApiRequest req = OpenApiRequest.build(TeaConverter.buildMap(
new TeaPair("headers", headers),
new TeaPair("body", com.aliyun.openapiutil.Client.parseToMap(body))
));
return TeaModel.toModel(this.doROARequestWithForm("ExecuteServerSideVerification", "2020-09-10", "HTTPS", "POST", "AK", "/viapi/thirdparty/realperson/execServerSideVerification", "json", req, runtime), new ExecuteServerSideVerificationResponse());
}
}
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
a49ae645f14ff6ad3d2bac9bb6eca1592141e76a | 45455d30fe2e81d26e706a99cc11321214713379 | /pawjdbc/src/main/java/com/capgemini/pawjdbc/util/JdbcUtil.java | 9a0a95974c9bad9e64686537d1812fc96d17269c | [] | no_license | aakashjain96/workspace | ac410076a46c6b7e54fd9f3f3edc8c115bdbf9e7 | b79f8e7a1301310740da2eed8e230dbb988610c8 | refs/heads/master | 2020-03-23T12:21:01.584769 | 2018-08-31T03:46:55 | 2018-08-31T03:46:55 | 141,383,376 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 582 | java | package com.capgemini.pawjdbc.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JdbcUtil {
public static Connection getConnection() {
Connection conn=null;
try {
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/wallet","root","Capgemini123");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
}
| [
"noreply@github.com"
] | aakashjain96.noreply@github.com |
7022cff6d4b7d6b5dc8a20038e070491d3daf89f | 4914e28784966a3750a7629c7e0c2e8fe4d70793 | /src/OctreeIterator.java | 8c20573eaf738bb2753de9492893f3cdf48ce29b | [] | no_license | MaxAlber/BarnesHut | e1111e96f64ee1d90d99bd30962fc4c826740340 | a3fde9143a58c6e44fcbf707800e8e7a14a9010f | refs/heads/master | 2022-12-15T06:44:21.313527 | 2020-09-13T16:22:26 | 2020-09-13T16:22:26 | 269,676,939 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 551 | java | import java.util.Iterator;
import java.util.Stack;
// this is an Iterator over the Octree
// to iterate over the octree a stack is used which stores all of the bodies of the tree
public class OctreeIterator implements Iterator<CelestialBody>
{
Stack<CelestialBody> stack;
public OctreeIterator(Stack<CelestialBody> stack)
{
this.stack = stack;
}
@Override
public boolean hasNext()
{
return !stack.isEmpty();
}
@Override
public CelestialBody next()
{
return stack.pop();
}
}
| [
"maxalber45@gmail.com"
] | maxalber45@gmail.com |
1ed088cabeec001d28178d036b7e8714553c992f | e72c6535aa08ca79f2c1df091e5130ec5a196d88 | /kodilla-spring/src/main/java/com/kodilla/spring/portfolio/TaskList.java | cbe19ab401de5b22c9cc853fa0633a9c3bb954c0 | [] | no_license | martyna30/Kalkulator | 4e39f3f88b42dab145b290678084cb28937bd8c8 | 5b0044748da261947a28072b228ad3167310e213 | refs/heads/master | 2020-09-25T08:16:08.547807 | 2020-08-14T09:11:35 | 2020-08-14T09:11:35 | 225,959,856 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 493 | java | package com.kodilla.spring.portfolio;
import java.util.ArrayList;
import java.util.List;
public class TaskList {
private List<String> tasks;
public TaskList() {
tasks = new ArrayList<>();
}
public void addTask(String task) {
this.tasks.add(task);
}
public List<String> getTasks() {
return tasks;
}
@Override
public String toString() {
return "TaskList{" +
"tasks=" + tasks +
'}';
}
}
| [
"prawdzikmartyna@op.pl"
] | prawdzikmartyna@op.pl |
fcb8b7ac7d249786d1d0961f28ed2868d7bdd773 | 8007dccad4c0aa985ba0e8fbc5100fddf5b56e46 | /src/main/java/puto/spoj/Rno_Dod.java | e10aed55f58cb5a19288d5c2ae1120fd3c8edd26 | [] | no_license | dorota-puto/excercises | b90f6f1ee5f6b1916fd736c5677f287114288296 | bebd6820b5b5ab4e96a38db1d470fe6c80451326 | refs/heads/master | 2022-04-04T22:47:15.032354 | 2020-01-10T21:38:41 | 2020-01-10T21:38:41 | 206,410,025 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 703 | java | package puto.spoj;
import java.util.Scanner;
public class Rno_Dod {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String tline = scanner.nextLine();
int t = Integer.parseInt(tline);
for (int i = 0; i < t; i++) {
int n = Integer.parseInt(scanner.nextLine());
String numberLine = scanner.nextLine();
String[] numberStrings = numberLine.split(" ");
int result = 0;
for (int j = 0; j < n; j++) {
int x = Integer.parseInt(numberStrings[j]);
result = result + x;
}
System.out.println("" + result);
}
}
}
| [
"dootras@gmail.com"
] | dootras@gmail.com |
e56c45d4e1de574b3bc202da34f6845774a0c710 | 06e2c8560b8254be17a3b1fa40e1b715d137d968 | /webapp-development-with-jboss-seam/seambook_nomikai/src/hot/dto/NomikaiDetailDto.java | ec6c1051b0e0231c184fd8501654f40731482aa0 | [] | no_license | yusuiked/tech-reading | 96770993777a2197cbf5c54953a3d69b7726a037 | 5fc5a4777919cc2f0f975683ec1d5eeae6f602a0 | refs/heads/master | 2021-10-08T05:24:36.102811 | 2018-12-08T10:17:34 | 2018-12-08T10:17:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 378 | java | package dto;
import java.io.Serializable;
import org.jboss.seam.annotations.Name;
@Name("nomikaiDetailDto")
public class NomikaiDetailDto implements Serializable {
private static final long serialVersionUID = 1L;
private Long nomikaiid;
public Long getNomikaiid() {
return nomikaiid;
}
public void setNomikaiid(Long nomikaiid) {
this.nomikaiid = nomikaiid;
}
}
| [
"yukung.i@gmail.com"
] | yukung.i@gmail.com |
d6fcebb6238b2db1656a12391087ab37fa09fc13 | 3a492d87ffc0e673878dbce45a5e171ce13eefb7 | /implementation/src/main/java/io/smallrye/mutiny/operators/UniRetryAtMost.java | b6de4e52f7ef5fdd784706810db1e71affa0b136 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | jlafourc/smallrye-mutiny | a56b48f4951bfe6a52b2a984989d7869154eff9e | 66e7b19e2b85fb1b7037a613a997531ad0f59e9b | refs/heads/master | 2022-11-25T21:20:51.021945 | 2020-07-23T16:54:07 | 2020-07-23T16:54:07 | 282,053,757 | 0 | 0 | Apache-2.0 | 2020-07-23T20:55:48 | 2020-07-23T20:55:48 | null | UTF-8 | Java | false | false | 3,026 | java | package io.smallrye.mutiny.operators;
import static io.smallrye.mutiny.helpers.EmptyUniSubscription.CANCELLED;
import static io.smallrye.mutiny.helpers.ParameterValidation.nonNull;
import static io.smallrye.mutiny.helpers.ParameterValidation.positive;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import io.smallrye.mutiny.Uni;
import io.smallrye.mutiny.helpers.Predicates;
import io.smallrye.mutiny.subscription.UniSubscriber;
import io.smallrye.mutiny.subscription.UniSubscription;
public class UniRetryAtMost<T> extends UniOperator<T, T> {
private final Predicate<? super Throwable> predicate;
private final long maxAttempts;
public UniRetryAtMost(Uni<T> upstream, Predicate<? super Throwable> predicate, long maxAttempts) {
super(nonNull(upstream, "upstream"));
this.predicate = nonNull(predicate, "predicate");
this.maxAttempts = positive(maxAttempts, "maxAttempts");
}
@Override
protected void subscribing(UniSerializedSubscriber<? super T> subscriber) {
AtomicInteger numberOfSubscriptions = new AtomicInteger(0);
UniSubscriber<T> retryingSubscriber = new UniSubscriber<T>() {
AtomicReference<UniSubscription> reference = new AtomicReference<>();
@Override
public void onSubscribe(UniSubscription subscription) {
if (numberOfSubscriptions.getAndIncrement() == 0) {
subscriber.onSubscribe(() -> {
UniSubscription old = reference.getAndSet(CANCELLED);
if (old != null) {
old.cancel();
}
});
} else {
reference.compareAndSet(null, subscription);
}
}
@Override
public void onItem(T item) {
if (reference.get() != CANCELLED) {
subscriber.onItem(item);
}
}
@Override
public void onFailure(Throwable failure) {
if (reference.get() != CANCELLED) {
if (!Predicates.testFailure(predicate, subscriber, failure)) {
return;
}
if (numberOfSubscriptions.get() > maxAttempts) {
subscriber.onFailure(failure);
return;
}
// retry.
UniSubscription old = reference.getAndSet(null);
if (old != null) {
old.cancel();
}
resubscribe(upstream(), this);
}
}
};
AbstractUni.subscribe(upstream(), retryingSubscriber);
}
private void resubscribe(Uni<? extends T> upstream, UniSubscriber<T> subscriber) {
AbstractUni.subscribe(upstream, subscriber);
}
}
| [
"clement.escoffier@gmail.com"
] | clement.escoffier@gmail.com |
dafd0326d16f988b7ebf4094e43a0b9fac83dda1 | 556cd753e0a83752d38c50d0555960872a5f6834 | /App/LegalFriend backend/legalfriendservice/src/main/java/com/legalfriend/webserviceprocessor/UserWebServiceDAOProcessor.java | ebcb5107a36bec40e4611cd30a134de3d92d5e25 | [] | no_license | kapilmoondra/Legal | 07763fec2f714e76c73c78cf067105c0dd8e3553 | db103deb6396a69f2fed32d9110cd7c23278721b | refs/heads/master | 2020-04-25T22:19:44.080447 | 2019-03-11T05:48:02 | 2019-03-11T05:48:02 | 173,107,873 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 473 | java | package com.legalfriend.webserviceprocessor;
import java.util.List;
import com.legalfriend.model.JwtAuthenticationToken;
import com.legalfriend.model.Role;
import com.legalfriend.model.User;
public interface UserWebServiceDAOProcessor {
Long signup(User user);
JwtAuthenticationToken loginUser(String username, String password);
List<User> listUser(String clientId);
User addUser(User user);
User editUser(User user);
List<Role> listRoles(String token);
}
| [
"kapil.moondra@gmail.com"
] | kapil.moondra@gmail.com |
562a18bed8fc8a7e4e3d7a88cb2bba151aeea563 | 0e215532ff745e93ec7ead9bdd749cf5e20a75bc | /src/com/hivegame/game/build/CommandNew.java | 2243a18b1b450adac6ae994bb1ff814521c0a82a | [] | no_license | msg138/HiveGame | 21867520db3fead74b0c1c37596cfd047e01d63e | 148652186b550373fdaf31a0a779c083d80931da | refs/heads/master | 2021-01-11T07:13:28.549624 | 2016-10-04T19:54:28 | 2016-10-04T19:54:28 | 70,000,627 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,197 | java | package com.hivegame.game.build;
import com.hivegame.game.chat.Command;
import com.retro.engine.camera.Camera;
import com.retro.engine.entity.Entity;
import com.retro.engine.util.vector.Vector3;
import com.hivegame.game.build.player.Player;
import com.hivegame.game.world.World;
/**
* Created by Michael on 8/9/2016.
*/
public class CommandNew extends Command {
public CommandNew(){
super("new");
}
public boolean onCommand(Entity user, String[] args){
Build.g_keepLower = false;
Build.g_animationMode = false;
boolean generateFlat = true;
if(args.length >= 2){
if(args[1].equalsIgnoreCase("blank")) {
generateFlat = false;
Build.g_keepLower = true;
}
}
World w = Player.getWorld(user);
if(generateFlat)
w.generateFlat();
w.generateSingleVoxel(!generateFlat);
Vector3 v = w.getMiddleChunkVoxel();
Camera.getInstance().getPosition().setX(v.getX());
Camera.getInstance().getPosition().setY(v.getY() + w.getVoxelSize()*2f);
Camera.getInstance().getPosition().setZ(v.getZ());
return true;
}
}
| [
"streetbard16@hotmail.com"
] | streetbard16@hotmail.com |
bf17336b386fe2e1e3aac31c349c8af118af866d | 128eb90ce7b21a7ce621524dfad2402e5e32a1e8 | /laravel-converted/src/main/java/com/project/convertedCode/includes/vendor/laravel/framework/src/Illuminate/Routing/Contracts/file_ControllerDispatcher_php.java | 1bd40cbf41734a94b7d1d637fe1fbbcafdfcfbf6 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | RuntimeConverter/RuntimeConverterLaravelJava | 657b4c73085b4e34fe4404a53277e056cf9094ba | 7ae848744fbcd993122347ffac853925ea4ea3b9 | refs/heads/master | 2020-04-12T17:22:30.345589 | 2018-12-22T10:32:34 | 2018-12-22T10:32:34 | 162,642,356 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,193 | java | package com.project.convertedCode.includes.vendor.laravel.framework.src.Illuminate.Routing.Contracts;
import com.runtimeconverter.runtime.RuntimeStack;
import com.runtimeconverter.runtime.interfaces.ContextConstants;
import com.runtimeconverter.runtime.includes.RuntimeIncludable;
import com.runtimeconverter.runtime.includes.IncludeEventException;
import com.runtimeconverter.runtime.classes.RuntimeClassBase;
import com.runtimeconverter.runtime.RuntimeEnv;
import com.runtimeconverter.runtime.interfaces.UpdateRuntimeScopeInterface;
import com.runtimeconverter.runtime.arrays.ZPair;
/*
Converted with The Runtime Converter (runtimeconverter.com)
vendor/laravel/framework/src/Illuminate/Routing/Contracts/ControllerDispatcher.php
*/
public class file_ControllerDispatcher_php implements RuntimeIncludable {
public static final file_ControllerDispatcher_php instance =
new file_ControllerDispatcher_php();
public final void include(RuntimeEnv env, RuntimeStack stack) throws IncludeEventException {
Scope1513 scope = new Scope1513();
stack.pushScope(scope);
this.include(env, stack, scope);
stack.popScope();
}
public final void include(RuntimeEnv env, RuntimeStack stack, Scope1513 scope)
throws IncludeEventException {
// Namespace import was here
// Conversion Note: class named ControllerDispatcher was here in the source code
env.addManualClassLoad("Illuminate\\Routing\\Contracts\\ControllerDispatcher");
}
private static final ContextConstants runtimeConverterContextContantsInstance =
new ContextConstants()
.setDir("/vendor/laravel/framework/src/Illuminate/Routing/Contracts")
.setFile(
"/vendor/laravel/framework/src/Illuminate/Routing/Contracts/ControllerDispatcher.php");
public ContextConstants getContextConstants() {
return runtimeConverterContextContantsInstance;
}
private static class Scope1513 implements UpdateRuntimeScopeInterface {
public void updateStack(RuntimeStack stack) {}
public void updateScope(RuntimeStack stack) {}
}
}
| [
"git@runtimeconverter.com"
] | git@runtimeconverter.com |
6aa0339b340c4e633de0a69c3b3dea1989a870b1 | 1c2876fc127029fce2fb83559cc32b569cc7f9dc | /client/src/main/java/org/ehrbase/client/openehrclient/EhrEndpoint.java | ba8a4d6012b8517a8c37ca0c57451e00c9b1a45a | [
"Apache-2.0"
] | permissive | NUM-Forschungsdatenplattform/CI-playground | a6162b23e6ef82b3f3882c954ca9d9f24c57af15 | 745eb2e48d19ef7768b61f225f259b96ebd8206b | refs/heads/develop | 2023-02-05T02:23:52.373761 | 2020-09-25T06:11:38 | 2020-09-25T06:11:38 | 295,705,260 | 0 | 0 | NOASSERTION | 2020-10-29T11:45:28 | 2020-09-15T11:27:17 | Java | UTF-8 | Java | false | false | 2,041 | java | /*
* Copyright (c) 2019 Stefan Spiska (Vitasystems GmbH) and Hannover Medical School
* This file is part of Project EHRbase
*
* 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.ehrbase.client.openehrclient;
import com.nedap.archie.rm.ehr.EhrStatus;
import org.ehrbase.client.exception.ClientException;
import org.ehrbase.client.exception.WrongStatusCodeException;
import java.util.Optional;
import java.util.UUID;
public interface EhrEndpoint {
/**
* Create a new EHR.
*
* @return ehrID
* @throws ClientException
* @throws WrongStatusCodeException
*/
UUID createEhr();
/**
* Create a new EHR with the given EHR_STATUS.
*
* @param ehrStatus EHR_STATUS object to create the EHR with.
* @return ehrID
* @throws ClientException
* @throws WrongStatusCodeException
*/
UUID createEhr(EhrStatus ehrStatus);
/**
* Get the EhrStatus for {@code ehrId}.
*
* @param ehrId Id of the ehr from which to return the status.
* @return {@link EhrStatus}
* @throws ClientException
* @throws WrongStatusCodeException
*/
Optional<EhrStatus> getEhrStatus(UUID ehrId);
/**
* Updates the status of the ehr with {@code ehrId} to {@code ehrStatus}
*
* @param ehrId EhrId of the ehr which will be updated
* @param ehrStatus new ehrStatus
* @throws ClientException
* @throws WrongStatusCodeException
*/
void updateEhrStatus(UUID ehrId, EhrStatus ehrStatus);
}
| [
"64201310+wlad@users.noreply.github.com"
] | 64201310+wlad@users.noreply.github.com |
64efee0131334addc60d8693d670d64a0d2e8e1e | bd4c1f1631e0a27b03a8f8238950164d69f6fe1f | /app/src/main/java/com/dev/weathertest/data/ApiManager.java | fcd5264584a1fa947c92053b2f17b65c09429ba5 | [] | no_license | AlexanderBelkin/WeatherTest | 329d060f4765c8335bb35bac5ebcaa2b2feed787 | cb65ab39cbf94e5b77357aa33602fe0f2407aa2f | refs/heads/master | 2021-07-23T14:58:23.151681 | 2017-11-02T11:23:24 | 2017-11-02T11:23:24 | 109,255,695 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 519 | java | package com.dev.weathertest.data;
import com.dev.weathertest.AppConstants;
import com.dev.weathertest.model.WeatherResp;
import io.reactivex.Single;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface ApiManager {
@GET(AppConstants.QUERY_LOCATION)
Single<WeatherResp> getWeather(@Query(AppConstants.LAT_QEURY) double lat,
@Query(AppConstants.LON_QEURY) double lng,
@Query(AppConstants.APP_ID_QEURY) String appid);
}
| [
"alexandr89nik@ukr.net"
] | alexandr89nik@ukr.net |
5e1dac8e51410ef186f9831e6de380f794b1aa66 | 26b7f30c6640b8017a06786e4a2414ad8a4d71dd | /src/number_of_direct_superinterfaces/i3548.java | ddf3946bbfd67c747a6c71764a8285943ab9d90e | [] | no_license | vincentclee/jvm-limits | b72a2f2dcc18caa458f1e77924221d585f23316b | 2fd1c26d1f7984ea8163bc103ad14b6d72282281 | refs/heads/master | 2020-05-18T11:18:41.711400 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 68 | java | package number_of_direct_superinterfaces;
public interface i3548 {} | [
"vincentlee.dolbydigital@yahoo.com"
] | vincentlee.dolbydigital@yahoo.com |
d52e70dee30cc1c94cd9721fc6e78d89af0b9e46 | 0937b5c17601e8bc12a46f34338e970872b7fb55 | /ex3/src/test/SaqueTest.java | 473663f2033eb331055972db01ea85599cff3811 | [] | no_license | leticiawanderley/es2 | 454b095ac9f10a36fe6d38b94cbe26de98398679 | 8b7c5e7603cf32f2729b14ebffe2c83555e2da59 | refs/heads/master | 2020-06-16T12:49:41.683874 | 2017-07-08T02:44:02 | 2017-07-08T02:44:02 | 94,146,571 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,579 | java | package test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import banking.Card;
import banking.Money;
public class SaqueTest {
private static final String USER_DETAILS = "USER_DETAILS";
private static final String SAQUE = "Saque";
ATMInterface atm;
Card cartaoOK = new Card(123);
int pinOk = 000;
String detalhesCertos = "Nome: Ok, Conta: OK";
String tipoDeContaExistente = "Savings";
@Before
public void setUp() throws Exception {
atm = new ATMInterface();
atm.setInitialCash(new Money(200));
atm.switchOn();
atm.insereCartao(cartaoOK);
atm.inserePin(pinOk);
atm.selecionaTransacao(SAQUE);
}
@Test
public void testRealizaSaque() {
float saldoAnterior = atm.getSaldoUsuario(tipoDeContaExistente);
atm.selecionaTipoDeConta(tipoDeContaExistente);
atm.insereDetalhes(detalhesCertos);
float saque = (float) 100.50;
atm.insereQuantidade(saque);
assertTrue(atm.dinheiroSuficiente());
assertTrue(atm.podeSacar());
assertEquals(saldoAnterior - saque, atm.getSaldoUsuario(tipoDeContaExistente), 0.0);
}
@Test
public void testRealizaSaqueSemDinheiroSuficiente() {
atm.selecionaTipoDeConta(tipoDeContaExistente);
atm.insereDetalhes(detalhesCertos);
float saque = (float) 100.50;
try {
atm.insereQuantidade(saque);
} catch (Exception e) {
assertFalse(atm.dinheiroSuficiente());
assertFalse(atm.podeSacar());
assertEquals(USER_DETAILS, atm.getCustomerConsoleStatus());
}
}
}
| [
"leticiafwanderley@gmail.com"
] | leticiafwanderley@gmail.com |
85460505282e36aa848e62f61133a855609364df | c726c1841de83617e615d6ca449fc0f56e4def87 | /app/src/main/java/com/example/icecream/database/AppDataBase.java | f3a22ab057ef771736f8577512b7a9d2968b7bb2 | [
"MIT"
] | permissive | PennaLai/IceCream | e20777d77b041dc4dedbb7302f58ca078924440f | 2bfe83e9d2be955205d2653efec4b8d957b3a44d | refs/heads/master | 2020-04-27T23:46:55.654495 | 2019-05-29T04:44:31 | 2019-05-29T04:44:31 | 174,789,824 | 1 | 3 | MIT | 2019-05-28T10:56:22 | 2019-03-10T07:08:53 | Java | UTF-8 | Java | false | false | 1,901 | java | package com.example.icecream.database;
import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;
import com.example.icecream.database.dao.ArticleDao;
import com.example.icecream.database.dao.RssFeedDao;
import com.example.icecream.database.dao.UserArticleJoinDao;
import com.example.icecream.database.dao.UserDao;
import com.example.icecream.database.dao.UserRssFeedJoinDao;
import com.example.icecream.database.entity.Article;
import com.example.icecream.database.entity.RssFeed;
import com.example.icecream.database.entity.User;
import com.example.icecream.database.entity.UserArticleJoin;
import com.example.icecream.database.entity.UserRssFeedJoin;
/**
* The local database class.
*
* @author Kemo
*/
@Database(entities = {User.class, RssFeed.class, Article.class,
UserRssFeedJoin.class, UserArticleJoin.class},
version = 1,
exportSchema = false)
public abstract class AppDataBase extends RoomDatabase {
// singleton
private static volatile AppDataBase instance;
public abstract UserDao userDao();
public abstract RssFeedDao rssFeedDao();
public abstract ArticleDao articleDao();
public abstract UserRssFeedJoinDao userRssFeedJoinDao();
public abstract UserArticleJoinDao userArticleJoinDao();
/**
* Get the singleton instance of the database.
*
* @param context app context.
* @return the singleton instance of the database.
* @author Kemo
*/
static AppDataBase getDatabase(final Context context) {
if (instance == null) {
synchronized (AppDataBase.class) {
if (instance == null) {
// create local database
instance = Room.databaseBuilder(context.getApplicationContext(),
AppDataBase.class, "app_database").build();
}
}
}
return instance;
}
}
| [
"11610728@mail.sustc.edu.cn"
] | 11610728@mail.sustc.edu.cn |
37ed067f684dd3663a352bb6133e177f05d288ae | d6b3d458c10b4982e73ca9134310e7eeb28ac212 | /src/牛客/_NC103_反转字符串.java | cae42d182621008dc1318ff9b255aed703224025 | [] | no_license | qxuewei/leetcode_java | d3899d39e4f101c49da49551c5a4b988428648ee | 9d8e7c7bbd38763ac8b3ff0ba24aea31a2294d98 | refs/heads/master | 2023-02-16T12:47:53.433710 | 2023-02-07T14:34:13 | 2023-02-07T14:34:13 | 203,576,323 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,046 | java | package 牛客;
// https://www.nowcoder.com/practice/c3a6afee325e472386a1c4eb1ef987f3?tpId=117&rp=1&ru=%2Fexam%2Foj&qru=%2Fexam%2Foj&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26pageSize%3D50%26search%3D%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D117&difficulty=&judgeStatus=&tags=&title=&gioEnter=menu
public class _NC103_反转字符串 {
// 双指针
public String reverse(String str) {
char[] strArray = str.toCharArray();
int left = 0;
int right = strArray.length - 1;
char tmp;
while (left < right) {
tmp = strArray[left];
strArray[left] = strArray[right];
strArray[right] = tmp;
left += 1;
right -= 1;
}
return new String(strArray);
}
public String reverse2(String str) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
buffer.insert(0, c);
}
return buffer.toString();
}
}
| [
"qiuxuewei@baidu.com"
] | qiuxuewei@baidu.com |
10e3addf3ebe25343e5422d18b2093e456584c82 | 620b3132a993ba5362575391d595d38e7d3e0098 | /src/com/chess/engine/Driver.java | 1ca1552bdf95a38b575c46de51d3d9af89c2603f | [] | no_license | NotameJackstone/Chess | c369086202cf13da8c1f6c893a2fb154ced29e40 | b544d601c50a244b1acb296b1625b975a8667fe9 | refs/heads/master | 2021-04-12T00:45:20.923039 | 2018-03-19T17:10:07 | 2018-03-19T17:10:07 | 125,893,568 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 226 | java | package com.chess.engine;
import com.chess.engine.board.Board;
public class Driver {
public static void main(String [] args){
Board board = Board.createStandardBoard();
System.out.println(board);
}
}
| [
"37550668+NotameJackstone@users.noreply.github.com"
] | 37550668+NotameJackstone@users.noreply.github.com |
b4ba63f58d589756597c2e90897a988d31ed7555 | d10afd6930db462403cc29f92f236eeac2d80da5 | /web/study/codes/thinkinjava/c07/Music2.java | f776b8f4ab0ee4d0a8ebd7bd3fe3126070200af8 | [] | no_license | poshidi/poshidiApp | 0a24d5f4e4788f2b4c44b71bf88e1eb99efe11c3 | 8de832a2a17a36b6913f47acd4534a6c621cd986 | refs/heads/master | 2021-01-10T05:18:34.041468 | 2016-02-26T09:54:43 | 2016-02-26T09:54:43 | 44,218,624 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,324 | java | /**
* Created by Administrator on 2016/1/15.
*/
//: Music2.java
// Overloading instead of upcasting
class Note2{
private int value;
private Note2(int val){
value = val;
}
public static final Note2
middleC = new Note2(0),
cSharp = new Note2(1),
cFlat = new Note2(2);
} //Etc.
class Instrument2{
public void play(Note2 n){
System.out.println("Instrument2.play()");
}
}
class Wind2 extends Instrument2{
public void play(Note2 n){
System.out.println("Wind2.play()");
}
}
class Stringed2 extends Instrument2{
public void play(Note2 n){
System.out.println("Stringed2.play()");
}
}
class Brass2 extends Instrument2{
public void play(Note2 n){
System.out.println("Brass2.play()");
}
}
public class Music2 {
public static void tune(Wind2 i){
i.play(Note2.middleC);
}
public static void tune(Stringed2 i){
i.play(Note2.middleC);
}
public static void tune(Brass2 i){
i.play(Note2.middleC);
}
public static void main(String[] args) {
Wind2 flute = new Wind2();
Stringed2 violin = new Stringed2();
Brass2 frenchHorn = new Brass2();
tune(flute); // No upcasting
tune(violin);
tune(frenchHorn);
}
} ///:~
| [
"375445831@qq.com"
] | 375445831@qq.com |
462dee9cc1e6dd856b7a25a405fd1a040f935bcd | ce7d99c6386cdd931cac9a88245dfa81b57a39b0 | /src/main/java/com/sharshar/coinswap/utils/ScratchConstants.java | 0543f4f073cb76715e0479b68b0ee2d530a4d916 | [] | no_license | lailasharshar/coinswap | 64ccb72a773401267e01c86fc20a40ff5af80ce4 | db8894ee59df6e5baaa1245e0e99e596cf009e18 | refs/heads/master | 2020-03-23T18:38:51.270578 | 2019-06-26T18:58:55 | 2019-06-26T18:58:55 | 141,922,485 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,335 | java | package com.sharshar.coinswap.utils;
import java.util.stream.Stream;
/**
* Reused constants for the application that don't need to be in a configuration file
*
* Created by lsharshar on 3/19/2018.
*/
public class ScratchConstants {
private ScratchConstants() { /* No need to instantiate this */}
public enum Exchange {
BINANCE((short) 1, "Binance"), CRYPTO_COMPARE((short) 2, "Crypto Compare");
private short value = 0;
private String exchangeName;
public String getExchangeName() {
return this.exchangeName;
}
public short getValue() {
return value;
}
public static Exchange valueOf(int value) {
return Stream.of(Exchange.values()).filter(c -> c.getValue() == value).findFirst().orElse(null);
}
Exchange(short value, String exchangeName) {
this.value = value;
this.exchangeName = exchangeName;
}
}
// The maximum amount of time this api can be down
// before the data is stale is 30 second
public static final long MAX_EXCHANGE_DOWN_TIME = 1000L * 30;
// The maximum amount of time this service can be down
// before the data in the database can't be trusted
public static final long MAX_TIME_BEFORE_RELOAD_REQUIRED = 1000L * 30;
public static final long ONE_DAY = 1000L * 60 * 60 * 24;
public enum CurrentSwapState {
OWNS_COIN_1,
OWNS_COIN_2,
OWNS_NOTHING
}
}
| [
"lsharshar@ncmec.org"
] | lsharshar@ncmec.org |
7e8553b995101a2f4283e0fa79ce536e18663747 | 67ef4052db4923d7e8ce2a8c0c4bc7dd030e768c | /src/main/java/com/estudo/servicoemail/consumers/EmailConsumer.java | d5e6334211c2bc8692efd5aafe3af8252dc9f078 | [] | no_license | franciscoslour/spring-rabbit-mq-consumer | dda3e6e3ea814b60ea57de984191bba4e2b73fb3 | 53c53e551e249bfefeb1ea10bcd94ab65a147d3d | refs/heads/main | 2023-07-06T13:54:48.904126 | 2021-08-09T14:25:23 | 2021-08-09T14:25:23 | 394,321,326 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 863 | java | package com.estudo.servicoemail.consumers;
import com.estudo.servicoemail.dto.EmailModelDto;
import com.estudo.servicoemail.model.EmailModel;
import com.estudo.servicoemail.service.EmailService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
@Component
public class EmailConsumer {
@Autowired
private EmailService emailService;
@RabbitListener(queues = "${spring.rabbitmq.queue}")
public void listen(@Payload EmailModelDto emailModelDto){
EmailModel emailModel = new EmailModel();
BeanUtils.copyProperties(emailModelDto,emailModel);
emailService.sendEmail(emailModel);
}
}
| [
"franciscolour2011@gmail.com"
] | franciscolour2011@gmail.com |
8747a16695f4d407d76fe297492fbfa671f5e53b | 7c0272f8e5daac66270e8d6a4f7ef2bf7d2a4e0f | /src/test/java/com/github/pedrovgs/problem76/InsertionSortTest.java | 064c0c98f902ebec966485aa7dfc339d9b9cd9d4 | [
"Apache-2.0"
] | permissive | pedrovgs/Algorithms | 46a75b0b93db0e8dfbed8fd3cd90a471c8d58a25 | b04396ba1a8bf094494f9ba514ecbe806fdb9776 | refs/heads/master | 2023-09-02T13:11:12.745595 | 2023-05-02T10:11:01 | 2023-05-02T10:11:01 | 26,398,337 | 3,177 | 1,013 | Apache-2.0 | 2023-06-24T04:38:33 | 2014-11-09T14:32:33 | Java | UTF-8 | Java | false | false | 995 | java | /*
* Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
*
* 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.github.pedrovgs.problem76;
import com.github.pedrovgs.sortingalgorithm.SortingAlgorithm;
import com.github.pedrovgs.sortingalgorithms.SortingAlgorithmTest;
/**
* @author Pedro Vicente Gómez Sánchez.
*/
public class InsertionSortTest extends SortingAlgorithmTest {
@Override public SortingAlgorithm getSortingAlgorithm() {
return new InsertionSort();
}
}
| [
"pedrovicente.gomez@gmail.com"
] | pedrovicente.gomez@gmail.com |
02301e9a14eceed1274099f3b4b05d3dc32b6cd9 | dd6f5b96cb466b3f6a3fed174734f7429b2f36be | /app/src/main/java/com/lianbei/taobu/utils/dbhelper/dao/OptDAPImpl.java | d9fb5929746cc6eb2b8692009c7f4eacbacebc04 | [] | no_license | EnoshChenXin/TaoBu_lb | 8738383e37b85adf99b16c2de2b8ef58f3377d53 | 9c5f7226ee4da88fd5e5108d5c6c72ce099751e8 | refs/heads/master | 2021-01-01T11:21:52.501630 | 2020-01-19T10:45:56 | 2020-01-19T10:45:56 | 239,256,546 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 9,457 | java | package com.lianbei.taobu.utils.dbhelper.dao;
import android.content.ContentValues;
import android.content.Context;
import android.util.Log;
import com.lianbei.taobu.constants.Constant;
import com.lianbei.taobu.shop.model.GoodsOptBean;
import com.lianbei.taobu.shop.model.SearchRecord;
import com.lianbei.taobu.utils.dbhelper.db.CarRentalDBHelper;
import com.lianbei.taobu.utils.dbhelper.db.SQLiteHelperFactory;
import com.lianbei.taobu.utils.dbhelper.db.TaoBuDBHelper;
import net.sqlcipher.Cursor;
import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteOpenHelper;
import java.util.ArrayList;
import java.util.List;
public class OptDAPImpl implements OptDAO{
private SQLiteOpenHelper sqLiteOpenHelper;
private String password = "";
SQLiteDatabase db = null;
public OptDAPImpl(Context context) {
sqLiteOpenHelper = SQLiteHelperFactory.create(context);
}
@Override
public long insertGoodsOpt(GoodsOptBean goodsOptBean) {
try {
db = sqLiteOpenHelper.getWritableDatabase(password);
ContentValues values = new ContentValues();
values.put(TaoBuDBHelper.OPT_KEY_OPT_ID,goodsOptBean.getOpt_id());
values.put(TaoBuDBHelper.OPT_KEY_OPT_NAME,String.valueOf(goodsOptBean.getOpt_name()));
values.put(TaoBuDBHelper.OPT_KEY_LEVEL,String.valueOf(goodsOptBean.getLevel()));
values.put(TaoBuDBHelper.OPT_KEY_PARENT_OPT_ID,String.valueOf(goodsOptBean.getParent_opt_id()));
return db.insert(TaoBuDBHelper.OPT_TABLE, null, values);
} finally {
// if (db != null)
// db.close();
}
}
@Override
public long insertSearchRecord(SearchRecord searchRecord) {
try {
db = sqLiteOpenHelper.getWritableDatabase(password);
ContentValues values = new ContentValues();
values.put(TaoBuDBHelper.SEARCH_KEY_SEARCH_RECORD,searchRecord.getKeywordRecord());
values.put(TaoBuDBHelper.SEARCH_KEY_HOT_NUMBER,searchRecord.getHotNum());
return db.insert(TaoBuDBHelper.SEARCH_RECORD_TABLE, null, values);
} finally {
// if (db != null)
// db.close();
}
}
@Override
public List<GoodsOptBean> queryOptBean() {
SQLiteDatabase db = null;
Cursor cursor = null;
try {
// db = sqLiteOpenHelper.getWritableDatabase(password);
// cursor = db.query("station_tb", new String[]{"latitude","longitude","operaionarea_group_name"}, null,
// null, null, null, null);
db = sqLiteOpenHelper.getWritableDatabase(password);
String sql = "select * from opt_tb";
// String sql = "select * from operation_area_tb";
cursor = db.rawQuery(sql, null);
List<GoodsOptBean> modelStationList = new ArrayList<GoodsOptBean>();
while (cursor != null && cursor.moveToNext()) {
GoodsOptBean goodsOptBean = new GoodsOptBean();
String opt_id = cursor.getString(cursor.getColumnIndex(TaoBuDBHelper.OPT_KEY_OPT_ID));
String opt_name = cursor.getString(cursor.getColumnIndex(TaoBuDBHelper.OPT_KEY_OPT_NAME));
String level = cursor.getString(cursor.getColumnIndex(TaoBuDBHelper.OPT_KEY_LEVEL));
String parent_opt_id = cursor.getString(cursor.getColumnIndex(TaoBuDBHelper.OPT_KEY_PARENT_OPT_ID));
goodsOptBean.setOpt_id(opt_id);
goodsOptBean.setOpt_name(opt_name);
goodsOptBean.setLevel(level);
goodsOptBean.setParent_opt_id(parent_opt_id);
modelStationList.add(goodsOptBean);
}
return modelStationList;
}finally {
if (cursor != null) {
cursor.close();
}
if (db != null)
db.close();
}
}
@Override
public List<SearchRecord> querySearchRecord() {
SQLiteDatabase db = null;
Cursor cursor = null;
try {
// db = sqLiteOpenHelper.getWritableDatabase(password);
// cursor = db.query("station_tb", new String[]{"latitude","longitude","operaionarea_group_name"}, null,
// null, null, null, null);
db = sqLiteOpenHelper.getWritableDatabase(password);
String sql = "select * from search_record_tb order by hot_num desc";
cursor = db.rawQuery(sql, null);
List<SearchRecord> searchRecords = new ArrayList<SearchRecord>();
while (cursor != null && cursor.moveToNext()) {
SearchRecord searchRecord = new SearchRecord();
String keywordRecord = cursor.getString(cursor.getColumnIndex(TaoBuDBHelper.SEARCH_KEY_SEARCH_RECORD));
int hotNum = cursor.getInt(cursor.getColumnIndex(TaoBuDBHelper.SEARCH_KEY_HOT_NUMBER));
searchRecord.setKeywordRecord(keywordRecord);
searchRecord.setHotNum(hotNum);
searchRecords.add(searchRecord);
}
return searchRecords;
}finally {
if (cursor != null) {
cursor.close();
}
if (db != null)
db.close();
}
}
@Override
public Cursor rawQuery() {
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = sqLiteOpenHelper.getWritableDatabase(password);
// String sql = "select * from station_tb s , operation_area_tb a where s.operation_area_group_id = a.operation_area_group_id";
// cursor = db.rawQuery(sql, null);
return cursor;
} finally {
// if (cursor != null) {
// cursor.close();
// }
// if (db != null)
// db.close();
}
}
/**
* search 模糊查询按照地址(搜索站点使用)
* @param search_address
* @return
*/
@Override
public Cursor getSerchGoodsOpt(String search_address) {
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = sqLiteOpenHelper.getWritableDatabase(password);
// String sql = "select * from station_tb where station_tb.station_name like ? ";
// String[] selectionArgs = new String[] { "%" + search_address+ "%" };
// Log.e("sql: ", sql);
// cursor = db.rawQuery(sql, selectionArgs);
return cursor;
} finally{
// if (cursor != null) {
// cursor.close();
// }
// if (db != null)
// db.close();
}
}
/**
* delete CarRentalDB
*
* @param context
* @return
*/
public boolean deleteDatabase(Context context) {
return context.deleteDatabase(CarRentalDBHelper.DATABASE_NAME);
}
/**
* This method will delete Station record.
*
* @return boolean
*/
public boolean deleteStation(Integer stationId) {
SQLiteDatabase db = null;
try {
db = sqLiteOpenHelper.getWritableDatabase(password);
return db.delete(CarRentalDBHelper.STATION_TABLE, CarRentalDBHelper.STATION_KEY_STATION_ID + " = "
+ stationId, null) > 0;
} finally{
// if (db != null)
// db.close();
}
}
/**
* 清空本地表数据
*/
public void clearTable(){
SQLiteDatabase db = null;
db = sqLiteOpenHelper.getWritableDatabase(password);
db.execSQL("DELETE FROM " +CarRentalDBHelper.OPERATION_AREA_TABLE);
db.execSQL("DELETE FROM " +CarRentalDBHelper.STATION_TABLE);
}
/**
* 清空本地表数据
*/
public void clearSearchTable(){
SQLiteDatabase db = null;
db = sqLiteOpenHelper.getWritableDatabase(password);
db.execSQL("DELETE FROM " +TaoBuDBHelper.SEARCH_RECORD_TABLE);
}
/**
* This method will update Station record.
* @return boolean
*/
public boolean updateStation(GoodsOptBean goodsOptBean) {
SQLiteDatabase db = null;
try {
db = sqLiteOpenHelper.getWritableDatabase(password);
ContentValues args = new ContentValues();
args.put(CarRentalDBHelper.OPT_KEY_OPT_ID, goodsOptBean.getOpt_id());
args.put(CarRentalDBHelper.OPT_KEY_OPT_NAME, goodsOptBean.getOpt_name());
args.put(CarRentalDBHelper.OPT_KEY_LEVEL, goodsOptBean.getLevel());
args.put(CarRentalDBHelper.OPT_KEY_PARENT_OPT_ID, goodsOptBean.getParent_opt_id());
return db.update(CarRentalDBHelper.OPT_TABLE, args, CarRentalDBHelper.OPT_KEY_OPT_ID + "="+ Integer.valueOf(goodsOptBean.getOpt_id()), null) > 0;
} finally{
// if (db != null)
// db.close();
}
}
/**
* This method will update Station record.
* @return boolean
*/
public boolean updateSearchRecord(SearchRecord searchRecord) {
SQLiteDatabase db = null;
try {
db = sqLiteOpenHelper.getWritableDatabase(password);
ContentValues args = new ContentValues();
args.put(TaoBuDBHelper.SEARCH_KEY_SEARCH_RECORD, searchRecord.getKeywordRecord());
args.put(TaoBuDBHelper.SEARCH_KEY_HOT_NUMBER, Integer.valueOf(searchRecord.getHotNum()));
return db.update(TaoBuDBHelper.SEARCH_RECORD_TABLE, args, TaoBuDBHelper.SEARCH_KEY_SEARCH_RECORD+"=?", new String[]{ searchRecord.getKeywordRecord()}) > 0;
} finally{
// if (db != null)
// db.close();
}
}
}
| [
"123456"
] | 123456 |
b78fa430cff1c5d17209ed4f6d9ae7447198743a | f3ed53704451a762efb292ea78a0082deb834186 | /demo/src/main/java/demo/javafx_samples/src/Ensemble8/src/compiletime/java/ensemble/compiletime/CodeGenerationUtils.java | a395f1920dc783c91e2a4e9dac80eb532264ea30 | [
"BSD-3-Clause"
] | permissive | kongzhidea/jdk-source | 8811c193b29cc638737079fb86585124a7780118 | edd6501bb03f6cc5dcc5c19d8de16bd7f9702afe | refs/heads/master | 2020-04-01T10:53:47.271739 | 2018-10-15T16:15:12 | 2018-10-15T16:15:12 | 153,136,405 | 2 | 0 | null | 2018-10-15T15:21:34 | 2018-10-15T15:21:34 | null | UTF-8 | Java | false | false | 7,520 | java | package demo.javafx_samples.src.Ensemble8.src.compiletime.java.ensemble.compiletime;
/*
* Copyright (c) 2008, 2014, Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
* This file is available and licensed under the following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the distribution.
* - Neither the name of Oracle Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import ensemble.compiletime.Sample.URL;
import java.util.*;
import javafx.application.ConditionalFeature;
/**
* A utils class containing static methods that are useful when generating Java code.
*/
public class CodeGenerationUtils {
public static List<Sample> ALL_SAMPLES = new ArrayList<Sample>();
public static Map<String,Set<String>> DOCS_TO_SAMPLE_MAP = new HashMap<String, Set<String>>();
public static String generateSampleRef(Sample sample) {
int sampleIndex = ALL_SAMPLES.indexOf(sample);
String sampleVarName;
if (sampleIndex < 0) {
sampleIndex = ALL_SAMPLES.size();
sampleVarName = getSampleVarName(sampleIndex);
ALL_SAMPLES.add(sample);
// add any document references to DOCS_TO_SAMPLE_MAP
for(String docRef: sample.apiClasspaths) {
addDocRef(docRef,sampleVarName);
}
for(URL docRef: sample.docsUrls) {
addDocRef(docRef.url, sampleVarName);
}
} else {
sampleVarName = getSampleVarName(sampleIndex);
}
return sampleVarName;
}
private static void addDocRef(String docUrl, String sampleVarName) {
Set<String> docRefList = DOCS_TO_SAMPLE_MAP.get(docUrl);
if (docRefList == null) {
docRefList = new HashSet<>();
DOCS_TO_SAMPLE_MAP.put(docUrl,docRefList);
}
docRefList.add(sampleVarName);
}
public static String getSampleVarName(int sampleIndex) {
return "SAMPLE_"+sampleIndex;
}
public static String generateCode(Sample sample) {
StringBuilder sb = new StringBuilder();
sb.append("new SampleInfo(");
sb.append(stringToCode(sample.name)); sb.append(',');
sb.append(stringToCode(sample.description)); sb.append(',');
sb.append(stringToCode(sample.ensemblePath)); sb.append(',');
sb.append(stringToCode(sample.baseUri)); sb.append(',');
sb.append(stringToCode(sample.appClass)); sb.append(',');
sb.append(stringToCode(sample.previewUrl)); sb.append(',');
sb.append(stringArrayToCode(sample.resourceUrls)); sb.append(',');
sb.append(stringArrayToCode(sample.apiClasspaths)); sb.append(',');
sb.append(urlArrayToCode(sample.docsUrls)); sb.append(',');
sb.append(stringArrayToCode(sample.relatesSamplePaths)); sb.append(',');
sb.append(stringToCode(sample.mainFileUrl)); sb.append(',');
sb.append(playgroundPropertyArrayToCode(sample.playgroundProperties)); sb.append(',');
sb.append(conditionalFeatureArrayToCode(sample.conditionalFeatures)); sb.append(',');
sb.append(Boolean.toString(sample.runsOnEmbedded));
sb.append(")");
return sb.toString();
}
public static String playgroundPropertyArrayToCode(List<Sample.PlaygroundProperty> array) {
StringBuilder sb = new StringBuilder();
sb.append("new PlaygroundProperty[]{");
for (Sample.PlaygroundProperty prop: array) {
sb.append("new PlaygroundProperty(");
sb.append(stringToCode(prop.fieldName));
sb.append(',');
sb.append(stringToCode(prop.propertyName));
for (Map.Entry<String,String> entry: prop.properties.entrySet()) {
sb.append(',');
sb.append(stringToCode(entry.getKey()));
sb.append(',');
sb.append(stringToCode(entry.getValue()));
}
sb.append("),");
}
sb.append("}");
return sb.toString();
}
public static String conditionalFeatureArrayToCode(List<ConditionalFeature> array) {
StringBuilder sb = new StringBuilder();
sb.append("new ConditionalFeature[]{");
for (ConditionalFeature feature : array) {
sb.append("ConditionalFeature.");
sb.append(feature.name());
sb.append(',');
}
sb.append("}");
return sb.toString();
}
public static String sampleArrayToCode(List<Sample> array) {
if (array == null || array.isEmpty()) return "null";
StringBuilder sb = new StringBuilder();
sb.append("new SampleInfo[]{");
for (Sample sample: array) {
sb.append(generateSampleRef(sample));
sb.append(',');
}
sb.append("}");
return sb.toString();
}
public static String stringArrayToCode(List<String> array) {
StringBuilder sb = new StringBuilder();
sb.append("new String[]{");
for (String string: array) {
sb.append(stringToCode(string));
sb.append(',');
}
sb.append("}");
return sb.toString();
}
public static String urlArrayToCode(List<URL> array) {
StringBuilder sb = new StringBuilder();
sb.append("new String[]{");
for (URL url: array) {
sb.append(stringToCode(url.url));
sb.append(',');
sb.append(stringToCode(url.name));
sb.append(',');
}
sb.append("}");
return sb.toString();
}
public static String variableNameArrayToCode(String className, Collection<String> array) {
StringBuilder sb = new StringBuilder();
sb.append("new "+className+"[]{");
for (String string: array) {
sb.append(string);
sb.append(',');
}
sb.append("}");
return sb.toString();
}
public static String stringToCode(String string) {
if (string == null) {
return "null";
} else {
return '\"' + string.replaceAll("\\\\", "\\\\\\\\") + '\"';
}
}
}
| [
"limm33@outlook.com"
] | limm33@outlook.com |
bf774f6acd64a2ee88367dc6c9b4c3831eea9e81 | 34e55a7531813c219c191f084196ebfe0d3d0b4c | /level20/lesson02/task04/Solution.java | 6c51e540ccb357fda074d14b6956b579fdbcbe50 | [] | no_license | bezobid/javarush | c5b8f09e78bc7020c00810ea4a82267ea30dab9f | 20a8b7e90a14a406b4fa02fc1b75707297d06428 | refs/heads/master | 2021-01-21T06:53:33.411811 | 2017-05-17T15:16:28 | 2017-05-17T15:16:28 | 91,590,091 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,094 | java | package com.javarush.test.level20.lesson02.task04;
import java.io.*;
import java.util.Scanner;
/* Читаем и пишем в файл статики
Реализуйте логику записи в файл и чтения из файла для класса ClassWithStatic
Метод load должен инициализировать объект включая статические поля данными из файла
Метод main реализован только для вас и не участвует в тестировании
*/
public class Solution {
public static void main(String[] args) {
//you can find your_file_name.tmp in your TMP directory or fix outputStream/inputStream according to your real file location
//вы можете найти your_file_name.tmp в папке TMP или исправьте outputStream/inputStream в соответствии с путем к вашему реальному файлу
try {
File your_file_name = new File ("c:/file");
OutputStream outputStream = new FileOutputStream(your_file_name);
InputStream inputStream = new FileInputStream(your_file_name);
ClassWithStatic classWithStatic = new ClassWithStatic();
classWithStatic.i = 3;
classWithStatic.j = 4;
classWithStatic.save(outputStream);
outputStream.flush();
ClassWithStatic loadedObject = new ClassWithStatic();
loadedObject.staticString = "something";
loadedObject.i = 6;
loadedObject.j = 7;
loadedObject.load(inputStream);
//check here that classWithStatic object equals to loadedObject object - проверьте тут, что classWithStatic и loadedObject равны
outputStream.close();
inputStream.close();
} catch (IOException e) {
//e.printStackTrace();
System.out.println("Oops, something wrong with my file");
} catch (Exception e) {
//e.printStackTrace();
System.out.println("Oops, something wrong with save/load method");
}
}
public static class ClassWithStatic {
public static String staticString = "it's test static string";
public int i;
public int j;
public void save(OutputStream outputStream) throws Exception {
//implement this method - реализуйте этот метод
String output = staticString + '\n' + this.i + '\n' + this.j;
outputStream.write(output.getBytes());
}
public void load(InputStream inputStream) throws Exception {
//implement this method - реализуйте этот метод
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNextLine())
{
staticString = scanner.nextLine();
this.i = Integer.parseInt(scanner.nextLine());
this.j = Integer.parseInt(scanner.nextLine());
}
}
}
}
| [
"sugubo@gmail.com"
] | sugubo@gmail.com |
018054c45a43dad7a7aaa6cc77e6dea5417a9e3b | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/34/34_efef6edcd7c9d74c0dda95945d609fa30d3dd137/SLIMProcessor/34_efef6edcd7c9d74c0dda95945d609fa30d3dd137_SLIMProcessor_s.java | a46f0d58b696e3fc64b32c8cb9cc642cc329b51a | [] | 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 | 48,775 | java | //
// SLIMProcessor.java
//
/*
SLIMPlugin for combined spectral-lifetime image analysis.
Copyright (c) 2010, UW-Madison LOCI
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the UW-Madison LOCI nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package loci.slim;
import ij.IJ;
import ij.ImagePlus;
import ij.gui.GenericDialog;
import ij.gui.Roi;
import ij.plugin.frame.RoiManager;
import ij.process.ColorProcessor;
import ij.process.ImageProcessor;
import imagej.imglib.process.ImageUtils;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.prefs.Preferences;
import javax.swing.JFrame;
import loci.slim.colorizer.DataColorizer;
import loci.slim.ui.IStartStopListener;
import loci.slim.ui.IUserInterfacePanel;
import loci.slim.ui.IUserInterfacePanel.FitAlgorithm;
import loci.slim.ui.IUserInterfacePanel.FitFunction;
import loci.slim.ui.IUserInterfacePanel.FitRegion;
import loci.slim.ui.IUserInterfacePanelListener;
import loci.slim.ui.UserInterfacePanel;
import loci.curvefitter.CurveFitData;
import loci.curvefitter.GrayCurveFitter;
import loci.curvefitter.GrayNRCurveFitter;
import loci.curvefitter.ICurveFitData;
import loci.curvefitter.ICurveFitter;
import loci.curvefitter.JaolhoCurveFitter;
import loci.curvefitter.MarkwardtCurveFitter;
import loci.curvefitter.SLIMCurveFitter;
import loci.formats.FormatTools;
import loci.formats.IFormatReader;
import loci.slim.analysis.SLIMAnalysis;
import loci.slim.binning.SLIMBinning;
import mpicbg.imglib.container.planar.PlanarContainerFactory;
import mpicbg.imglib.cursor.Cursor;
import mpicbg.imglib.cursor.LocalizableByDimCursor;
import mpicbg.imglib.image.Image;
import mpicbg.imglib.image.ImageFactory;
import mpicbg.imglib.io.ImageOpener;
import mpicbg.imglib.type.numeric.RealType;
import mpicbg.imglib.type.numeric.real.DoubleType;
//TODO tidy up SLIMProcessor
/**
* SLIMProcessor is the main class of the SLIM Plugin. It was originally just thrown
* together to get something working, with some code/techniques borrowed from SLIM Plotter.
* Parts of this code are ugly & experimental.
*
* @author Aivar Grislis grislis at wisc.edu
*/
public class SLIMProcessor <T extends RealType<T>> {
private static final String X = "X";
private static final String Y = "Y";
private static final String LIFETIME = "Lifetime";
private static final String CHANNELS = "Channels";
private static final boolean USE_TAU = true;
private static final boolean USE_LAMBDA = false;
// this affects how lifetimes are colorized: //TODO get rid of this
private static final double MAXIMUM_LIFETIME = 0.075; // for fitting fake with Jaolho // for fitting brian with barber triple integral 100.0f X tau vs lambda issue here
// this affects how many pixels we process at once
private static final int PIXEL_COUNT = 128; //32;//16;
// Unicode special characters
private static final Character CHI = '\u03c7';
private static final Character SQUARE = '\u00b2';
private static final Character TAU = '\u03c4';
private static final Character LAMBDA = '\u03bb';
private static final Character SIGMA = '\u03c3';
private static final Character SUB_1 = '\u2081';
private static final Character SUB_2 = '\u2082';
private static final Character SUB_3 = '\u2083';
private static final double[] DEFAULT_SINGLE_EXP_PARAMS = { 0.0, 0.5, 100.0, 0.5 }; // 0 C A T
private static final double[] DEFAULT_DOUBLE_EXP_PARAMS = { 0.0, 0.5, 50.0, 0.5, 50, 0.25 }; // 0 C A1 T1 A2 T2
private static final double[] DEFAULT_TRIPLE_EXP_PARAMS = { 0.0, 0.5, 40.0, 0.5, 30.0, 0.25, 30, 0.10 }; // 0 C A1 T1 A2 T2 A3 T3
private static final double[] DEFAULT_STRETCH_EXP_PARAMS = { 0.0, 0.5, 100.0, 0.5, 0.5 }; // 0 C A T H
private Object m_synchFit = new Object();
private volatile boolean m_quit;
private volatile boolean m_cancel;
private volatile boolean m_fitInProgress;
private volatile boolean m_fitted;
//TODO total kludge; just to get started
private boolean m_fakeData = false;
private static final String FILE_KEY = "file";
private String m_file;
IFormatReader m_reader;
private Image<T> m_image;
private LocalizableByDimCursor<T> m_cursor;
// Actual data values, dimensioned [channel][row][column][bin] //TODO DEPRECATE
protected int[][][][] Xm_data;
private ImageProcessor m_grayscaleImageProcessor;
private Canvas m_grayscaleCanvas;
private Image<DoubleType> m_fittedImage = null;
private int m_fittedParameterCount = 0;
boolean m_visibleFit = true;
// data parameters
private boolean m_hasChannels;
private int m_channels;
private int m_width;
private int m_height;
private int[] m_cLengths;
private int m_timeBins;
private int m_lifetimeIndex;
private int m_spectraIndex;
private boolean m_little;
private int m_pixelType;
private int m_bpp;
private boolean m_floating;
private float m_timeRange;
private int m_minWave, m_waveStep; //, m_maxWave;
private FitRegion m_region;
private FitAlgorithm m_algorithm;
private FitFunction m_function;
private SLIMAnalysis m_analysis;
private SLIMBinning m_binning;
private IGrayScaleImage m_grayScaleImage;
// user sets these from the grayScalePanel
private int m_channel;
private boolean m_fitAllChannels;
// current channel, x, y
private int m_xchannel; // channel to fit; -1 means fit all channels
private int m_x;
private int m_y;
private int m_xvisibleChannel; // channel being displayed; -1 means none
private double[] m_param = new double[7];
private boolean[] m_free = { true, true, true, true, true, true, true };
private int m_startBin;
private int m_stopBin;
private int m_startX;
private int m_threshold;
private float m_chiSqTarget;
private int m_debug = 0;
public SLIMProcessor() {
m_analysis = new SLIMAnalysis();
m_binning = new SLIMBinning();
m_quit = false;
m_cancel = false;
m_fitInProgress = false;
m_fitted = false;
}
public void processImage(Image<T> image) {
boolean success = false;
m_image = image;
if (getImageInfo(image)) {
// show the UI; do fits
doFits();
}
}
/**
* Run method for the plugin. Throws up a file dialog.
*
* @param arg
*/
public void process(String arg) {
boolean success = false;
if (showFileDialog(getFileFromPreferences())) {
if (m_fakeData) {
fakeData();
success = true;
}
else {
m_image = loadImage(m_file);
if (getImageInfo(m_image)) {
saveFileInPreferences(m_file);
success = true;
}
}
}
if (success) {
// show the UI; do fits
doFits();
}
}
/**
* Creates a user interface panel. Shows a grayscale
* version of the image.
*
* Loops until quitting time and handles fit requests.
* Fitting is driven by a button on the UI panel which
* sets the global m_fitInProgress.
*
* @param uiPanel
*/
private void doFits() {
// show the UI; do fits
final IUserInterfacePanel uiPanel = new UserInterfacePanel(USE_TAU, m_analysis.getChoices(), m_binning.getChoices());
uiPanel.setX(0);
uiPanel.setY(0);
uiPanel.setStart(m_timeBins / 2); //TODO hokey
uiPanel.setStop(m_timeBins - 1);
uiPanel.setThreshold(100);
uiPanel.setFunctionParameters(0, DEFAULT_SINGLE_EXP_PARAMS);
uiPanel.setFunctionParameters(1, DEFAULT_DOUBLE_EXP_PARAMS);
uiPanel.setFunctionParameters(2, DEFAULT_TRIPLE_EXP_PARAMS);
uiPanel.setFunctionParameters(3, DEFAULT_STRETCH_EXP_PARAMS);
uiPanel.setListener(
new IUserInterfacePanelListener() {
public void doFit() {
m_cancel = false;
m_fitInProgress = true;
}
public void cancelFit() {
m_cancel = true;
}
public void quit() {
m_quit = true;
}
}
);
uiPanel.getFrame().setLocationRelativeTo(null);
uiPanel.getFrame().setVisible(true);
// create a grayscale image from the data
m_grayScaleImage = new GrayScaleImage("TITLE", m_image);
m_grayScaleImage.setListener(
new ISelectListener() {
public void selected(int channel, int x, int y) {
// just ignore clicks during a fit
if (!m_fitInProgress) {
synchronized (m_synchFit) {
uiPanel.setX(x);
uiPanel.setY(y);
// fit on the pixel clicked
fitPixel(uiPanel, x, y);
}
}
}
}
);
// processing loop; waits for UI panel input
while (!m_quit) {
while (!m_fitInProgress) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}
if (m_quit) {
return;
}
}
//uiPanel.enable(false); //TODO this might be better to be same as grayScalePanel
m_grayScaleImage.enable(false);
// get settings of requested fit
getFitSettings(m_grayScaleImage, uiPanel);
// do the fit
fitData(uiPanel);
m_fitInProgress = false;
//uiPanel.enable(true);
m_grayScaleImage.enable(true);
uiPanel.reset();
}
}
private void getFitSettings(IGrayScaleImage grayScalePanel, IUserInterfacePanel uiPanel) {
m_channel = grayScalePanel.getChannel();
m_region = uiPanel.getRegion();
m_algorithm = uiPanel.getAlgorithm();
m_function = uiPanel.getFunction();
m_fitAllChannels = uiPanel.getFitAllChannels();
m_x = uiPanel.getX();
m_y = uiPanel.getY();
m_startBin = uiPanel.getStart();
m_stopBin = uiPanel.getStop();
m_threshold = uiPanel.getThreshold();
m_param = uiPanel.getParameters();
m_free = uiPanel.getFree();
}
/**
* Prompts for a .sdt file.
*
* @param defaultFile
* @return
*/
private boolean showFileDialog(String defaultFile) {
//TODO shouldn't UI be in separate class?
//TODO need to include fiji-lib.jar in repository:
//GenericDialogPlus dialog = new GenericDialogPlus("Load Data");
GenericDialog dialog = new GenericDialog("Load Data");
//TODO works with GenericDialogPlus, dialog.addFileField("File:", defaultFile, 24);
dialog.addStringField("File", defaultFile);
dialog.addCheckbox("Fake data", m_fakeData);
dialog.showDialog();
if (dialog.wasCanceled()) {
return false;
}
m_file = dialog.getNextString();
m_fakeData = dialog.getNextBoolean();
return true;
}
private Image<T> loadImage(String file) {
ImageOpener imageOpener = new ImageOpener();
Image<T> image = null;
try {
image = imageOpener.openImage(file);
}
catch (Exception e) {
System.out.println("Error " + e.getMessage());
}
return image;
}
private boolean getImageInfo(Image<T> image) {
System.out.println("Image is " + image);
int[] dimensions = image.getDimensions();
System.out.println("dimensions size is " + dimensions.length);
Integer xIndex, yIndex, lifetimeIndex, channelIndex;
m_width = ImageUtils.getWidth(image);
m_height = ImageUtils.getHeight(image);
m_channels = ImageUtils.getNChannels(image);
//TODO this is broken; returns 1 when there are 16 channels; corrected below
System.out.println("ImageUtils.getNChannels returns " + m_channels);
m_hasChannels = false;
if (dimensions.length > 3) {
m_hasChannels = true;
m_channels = dimensions[3];
}
System.out.println("corrected to " + m_channels);
m_timeBins = ImageUtils.getDimSize(image, FormatTools.LIFETIME);
System.out.println("width " + m_width + " height " + m_height + " timeBins " + m_timeBins + " channels " + m_channels);
m_cursor = image.createLocalizableByDimCursor();
/*
int index = 0;
xIndex = index++;
yIndex = index++;
lifetimeIndex = index++;
if (m_channels > 1) {
channelIndex = index;
}
else {
channelIndex = null;
}
m_data = new int[m_channels][m_height][m_width][m_timeBins];
final LocalizableByDimCursor<T> cursor = image.createLocalizableByDimCursor();
int x, y, bin, channel;
for (channel = 0; channel < m_channels; ++channel) {
if (null != channelIndex) {
dimensions[channelIndex] = channel;
}
for (y = 0; y < m_height; ++y) {
dimensions[yIndex] = y;
for (x = 0; x < m_width; ++x) {
dimensions[xIndex] = x;
for (bin = 0; bin < m_timeBins; ++bin) {
dimensions[lifetimeIndex] = bin;
cursor.moveTo(dimensions);
m_data[channel][y][x][bin] = (int) cursor.getType().getRealFloat();
//TODO don't do this, screws up low photon count images... m_data[channel][y][x][bin] /= 10.0f; //TODO in accordance with TRI2; HOLY COW!!! ALSO int vs float??? why?
}
}
}
}
cursor.close();*/
// print out some useful information about the image
//System.out.println(image);
//final Cursor<T> cursor = image.createCursor();
//cursor.fwd();
//System.out.println("\tType = " + cursor.getType().getClass().getName());
//cursor.close();
//TODO from a former version:
//TODO won't compile with my version of the jar: Number timeBase = (Number) m_reader.getGlobalMetadata().get("time base");
//TODO fix:
// Number timeBase = null;
// m_timeRange = timeBase == null ? Float.NaN : timeBase.floatValue();
//// if (m_timeRange != m_timeRange) m_timeRange = 10.0f;
// m_minWave = 400;
// m_waveStep = 10;
//m_binRadius = 3;
// patch things up
m_timeRange = 10.0f / 64.0f; //TODO ARG this patches things up in accord with TRI2 for brian/gpl1.sdt; very odd value here NOTE this was with photon counts all divided by 10.0f above! might have cancelled out.
//TODO the patch above worked when I was also dividing the photon count by 10.0f!! should be 1/64?
m_minWave = 400;
m_waveStep = 10;
return true;
}
private boolean fakeData() {
return true;
}
/**
* This routine creates an artificial set of data that is useful to test fitting.
*
* @return whether successful
*/
/* private boolean fakeData() {
m_width = 50;
m_height = 50;
m_timeBins = 20;
m_channels = 1;
m_timeRange = 10.0f;
m_minWave = 400;
m_waveStep = 10;
double A;
double lambda;
double b = 1.0;
// show colorized lifetimes
DataColorizer dataColorizer = new DataColorizer(m_width, m_height, "Fake Data");
//ImageProcessor imageProcessor = new ColorProcessor(m_width, m_height);
//ImagePlus imagePlus = new ImagePlus("Fake Data", imageProcessor);
m_data = new int[m_channels][m_height][m_width][m_timeBins];
for (int y = 0; y < m_height; ++y) {
A = 1000.0 + y * 10000.0; // was 1000.0; bumped up Tuesday July 27 trying to get Barber LMA to work - didn't help.
for (int x = 0; x < m_width; ++x) {
double tmpX = x;
lambda = 0.05 + x * 0.0005d; //0.0001 + x * .001; //0.5 + x * 0.01; // .002500 + x * .01;
//System.out.println("lambda " + lambda + " color " + lambdaColorMap(MAXIMUM_LAMBDA, lambda));
dataColorizer.setData(true, x, y, lambda);
//imageProcessor.setColor(lifetimeColorMap(MAXIMUM_LIFETIME, lambda));
//imageProcessor.drawPixel(x, y);
for (int t = 0; t < m_timeBins; ++t) {
m_data[0][y][x][t] = (int)(A * Math.exp(-lambda * m_timeRange * t) + b);
}
//System.out.print(" " + m_data[0][y][x][0]);
if (5 == x && 5 == y) System.out.println("at (5, 5) A is " + A + " lambda " + lambda + " b " + b);
if (10 == x && 10 == y) System.out.println("at (10, 10) A is " + A + " lambda " + lambda + " b " + b);
if (49 == x && 49 == y) System.out.println("at (49, 49) A is " + A + " lambda " + lambda + " b " + b);
}
//System.out.println();
}
dataColorizer.update();
return true;
}
*/
/**
* Restores file name from Java Preferences.
*
* @return file name String
*/
private String getFileFromPreferences() {
Preferences prefs = Preferences.userNodeForPackage(this.getClass());
return prefs.get(FILE_KEY, "");
}
/**
* Saves the file name to Java Preferences.
*
* @param file
*/
private void saveFileInPreferences(String file) {
Preferences prefs = Preferences.userNodeForPackage(this.getClass());
prefs.put(FILE_KEY, file);
}
/*
* Fits the data as requested by UI.
*/
private void fitData(IUserInterfacePanel uiPanel) {
// only one fit at a time
synchronized (m_synchFit) {
switch (m_region) {
case SUMMED:
// sum all pixels
fitSummed(uiPanel);
break;
case ROI:
// fit summed ROIs
fitROIs(uiPanel);
break;
case POINT:
// fit single pixel
fitPixel(uiPanel, m_x, m_y);
break;
case EACH:
// fit every pixel
fitEachPixel(uiPanel);
break;
}
}
m_analysis.doAnalysis(uiPanel.getAnalysis(), m_fittedImage, uiPanel.getRegion(), uiPanel.getFunction()); //TODO get from uiPanel or get from global? re-evaluate approach here
}
/*
* Sums all pixels and fits the result.
*/
private void fitSummed(IUserInterfacePanel uiPanel) {
double params[] = uiPanel.getParameters(); //TODO go cumulative
// build the data
ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>();
ICurveFitData curveFitData;
double yCount[];
double yFitted[];
// sum up all the photons
curveFitData = new CurveFitData();
curveFitData.setParams(params);
yCount = new double[m_timeBins];
for (int b = 0; b < m_timeBins; ++b) {
yCount[b] = 0.0;
}
int photons = 0;
if (-1 == m_channel) {
// sum all of the channels
for (int channel = 0; channel < m_channels; ++channel) {
for (int y = 0; y < m_height; ++y) {
for (int x = 0; x < m_width; ++x) {
for (int b = 0; b < m_timeBins; ++b) {
double count = getData(m_cursor, channel, x, y, b);
yCount[b] += count;
photons += (int) count;
}
}
}
}
}
else {
// sum selected channel
for (int y = 0; y < m_height; ++y) {
for (int x = 0; x < m_width; ++x) {
for (int b = 0; b < m_timeBins; ++b) {
double count = getData(m_cursor, m_channel, x, y, b);
yCount[b] += count;
photons += (int) count;
}
}
}
}
System.out.println("Summed photons " + photons);
curveFitData.setYCount(yCount);
yFitted = new double[m_timeBins];
curveFitData.setYFitted(yFitted);
curveFitDataList.add(curveFitData);
// do the fit
ICurveFitData dataArray[] = curveFitDataList.toArray(new ICurveFitData[0]);
getCurveFitter(uiPanel).fitData(dataArray, m_startBin, m_stopBin);
// show decay and update UI parameters
showDecayGraph(uiPanel, dataArray);
uiPanel.setParameters(dataArray[0].getParams());
}
/*
* Sums and fits each ROI.
*/
private void fitROIs(IUserInterfacePanel uiPanel) {
double params[] = uiPanel.getParameters();
// build the data
ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>();
ICurveFitData curveFitData;
double yCount[];
double yFitted[];
int roiNumber = 0;
for (Roi roi: getRois()) {
++roiNumber;
curveFitData = new CurveFitData();
curveFitData.setParams(params.clone());
yCount = new double[m_timeBins];
for (int b = 0; b < m_timeBins; ++b) {
yCount[b] = 0.0;
}
Rectangle bounds = roi.getBounds();
for (int x = 0; x < bounds.width; ++x) {
for (int y = 0; y < bounds.height; ++y) {
if (roi.contains(bounds.x + x, bounds.y + y)) {
System.out.println("roi " + roiNumber + " x " + x + " Y " + y);
for (int b = 0; b < m_timeBins; ++b) {
yCount[b] += getData(m_cursor, m_channel, x, y, b);
}
}
}
}
curveFitData.setYCount(yCount);
yFitted = new double[m_timeBins];
curveFitData.setYFitted(yFitted);
curveFitDataList.add(curveFitData);
}
// do the fit
ICurveFitData dataArray[] = curveFitDataList.toArray(new ICurveFitData[0]);
getCurveFitter(uiPanel).fitData(dataArray, m_startBin, m_stopBin);
showDecayGraph(uiPanel, dataArray);
// show colorized lifetimes
ImageProcessor imageProcessor = new ColorProcessor(m_width, m_height);
ImagePlus imagePlus = new ImagePlus("Fitted Lifetimes", imageProcessor);
int i = 0;
for (Roi roi: getRois()) {
double lifetime = dataArray[i++].getParams()[1];
imageProcessor.setColor(lifetimeColorMap(MAXIMUM_LIFETIME, lifetime));
Rectangle bounds = roi.getBounds();
for (int x = 0; x < bounds.width; ++x) {
for (int y = 0; y < bounds.height; ++y) {
if (roi.contains(bounds.x + x, bounds.y + y)) {
imageProcessor.drawPixel(bounds.x + x, bounds.y + y);
}
}
}
}
imagePlus.show();
// update UI parameters
uiPanel.setParameters(dataArray[0].getParams()); //TODO, just picked first ROI here!
}
/*
* Fits a given pixel.
*
* @param x
* @param y
*/
private void fitPixel(IUserInterfacePanel uiPanel, int x, int y) {
double params[] = uiPanel.getParameters();
// build the data
ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>();
ICurveFitData curveFitData;
double yCount[];
double yFitted[];
curveFitData = new CurveFitData();
curveFitData.setParams(params);
yCount = new double[m_timeBins];
for (int b = 0; b < m_timeBins; ++b) {
yCount[b] = getData(m_cursor, m_channel, x, m_height - y - 1, b);
}
curveFitData.setYCount(yCount);
yFitted = new double[m_timeBins];
curveFitData.setYFitted(yFitted);
curveFitDataList.add(curveFitData);
// do the fit
ICurveFitData dataArray[] = curveFitDataList.toArray(new ICurveFitData[0]);
getCurveFitter(uiPanel).fitData(dataArray, m_startBin, m_stopBin);
showDecayGraph(uiPanel, dataArray);
// update UI parameters
uiPanel.setParameters(dataArray[0].getParams());
}
/*
* Fits each and every pixel. This is the most complicated fit.
*
* If a channel is visible it is fit first and drawn incrementally.
*
* Results of the fit go to VisAD for analysis.
*/
private void fitEachPixel(IUserInterfacePanel uiPanel) {
long start = System.nanoTime();
int pixelCount = 0;
int totalPixelCount = totalPixelCount(m_width, m_height, m_channels, m_fitAllChannels);
int pixelsToProcessCount = 0;
Image<T> workImage = m_image;
if (!SLIMBinning.NONE.equals(uiPanel.getBinning())) {
workImage = m_binning.doBinning(uiPanel.getBinning(), m_image);
}
LocalizableByDimCursor<T> pixelCursor = workImage.createLocalizableByDimCursor();
ICurveFitter curveFitter = getCurveFitter(uiPanel);
double params[] = uiPanel.getParameters();
boolean useFittedParams;
LocalizableByDimCursor<DoubleType> resultsCursor = null;
if (null == m_fittedImage || uiPanel.getParameterCount() != m_fittedParameterCount) {
// can't use previous results
useFittedParams = false;
int channels = m_channels;
m_fittedParameterCount = uiPanel.getParameterCount();
m_fittedImage = makeImage(channels, m_width, m_height, m_fittedParameterCount);
}
else {
// ask UI whether to use previous results
useFittedParams = uiPanel.refineFit();
}
resultsCursor = m_fittedImage.createLocalizableByDimCursor();
// build the data
ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>();
ArrayList<ChunkyPixel> pixelList = new ArrayList<ChunkyPixel>();
ICurveFitData curveFitData;
double yCount[];
double yFitted[];
// special handling for visible channel
if (m_visibleFit) {
// show colorized image
DataColorizer dataColorizer = new DataColorizer(m_width, m_height, m_algorithm + " Fitted Lifetimes");
ChunkyPixelEffectIterator pixelIterator = new ChunkyPixelEffectIterator(new ChunkyPixelTableImpl(), m_width, m_height);
while (!m_cancel && pixelIterator.hasNext()) {
if (m_cancel) {
IJ.showProgress(0, 0); //TODO kludgy to have this here and also below; get rid of this but make the dataColorizer go away regardless
dataColorizer.quit();
cancelImageFit();
return;
}
IJ.showProgress(++pixelCount, totalPixelCount);
ChunkyPixel pixel = pixelIterator.next();
if (wantFitted(m_channel, pixel.getX(), pixel.getY())) {
curveFitData = new CurveFitData();
curveFitData.setChannel(m_channel);
curveFitData.setX(pixel.getX());
curveFitData.setY(pixel.getY());
curveFitData.setParams(
useFittedParams ?
getFittedParams(resultsCursor, m_channel, pixel.getX(), pixel.getY(), m_fittedParameterCount) :
params.clone());
yCount = new double[m_timeBins];
for (int b = 0; b < m_timeBins; ++b) {
yCount[b] = getData(pixelCursor, m_channel, pixel.getX(), pixel.getY(), b); //binnedData[m_channel][pixel.getY()][pixel.getX()][b];
}
curveFitData.setYCount(yCount);
yFitted = new double[m_timeBins];
curveFitData.setYFitted(yFitted);
curveFitDataList.add(curveFitData);
pixelList.add(pixel);
// process the pixels
if (++pixelsToProcessCount >= PIXEL_COUNT) {
pixelsToProcessCount = 0;
ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]);
curveFitDataList.clear();
curveFitter.fitData(data, m_startBin, m_stopBin);
setFittedParamsFromData(resultsCursor, data);
colorizePixels(dataColorizer, m_height, m_channel, data, pixelList.toArray(new ChunkyPixel[0]));
pixelList.clear();
}
}
}
// handle any leftover pixels
if (!m_cancel && pixelsToProcessCount > 0) {
pixelsToProcessCount = 0;
ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]);
curveFitDataList.clear();
curveFitter.fitData(data, m_startBin, m_stopBin);
setFittedParamsFromData(resultsCursor, data);
colorizePixels(dataColorizer, m_height, m_channel, data, pixelList.toArray(new ChunkyPixel[0]));
}
}
if (m_cancel) {
IJ.showProgress(0, 0); //TODO the code below s/b showing progress also
// dataColorizer.quit(); //TODO no longer visible in this code
cancelImageFit();
return;
}
// any channels still to be fitted?
for (int channel : channelIndexArray(m_channel, m_channels, m_visibleFit, m_fitAllChannels)) {
for (int y = 0; y < m_height; ++y) {
for (int x = 0; x < m_width; ++x) {
if (m_visibleFit) {
IJ.showProgress(++pixelCount, totalPixelCount);
}
if (wantFitted(channel, x, y)) {
++pixelsToProcessCount;
curveFitData = new CurveFitData();
curveFitData.setChannel(channel);
curveFitData.setX(x);
curveFitData.setY(y);
curveFitData.setParams(
useFittedParams ?
getFittedParams(resultsCursor, channel, x, y, m_fittedParameterCount) :
params.clone());
yCount = new double[m_timeBins];
for (int b = 0; b < m_timeBins; ++b) {
yCount[b] = getData(pixelCursor, channel, x, y, b); //binnedData[channel][y][x][b];
}
curveFitData.setYCount(yCount);
yFitted = new double[m_timeBins];
curveFitData.setYFitted(yFitted);
curveFitDataList.add(curveFitData);
}
if (m_cancel) {
cancelImageFit();
return;
}
}
// every row, process pixels as needed
if (pixelsToProcessCount >= PIXEL_COUNT) {
pixelsToProcessCount = 0;
ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]);
curveFitDataList.clear();
curveFitter.fitData(data, m_startBin, m_stopBin);
setFittedParamsFromData(resultsCursor, data);
}
}
}
// handle any leftover pixels
if (pixelsToProcessCount > 0) {
ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]);
curveFitter.fitData(data, m_startBin, m_stopBin);
setFittedParamsFromData(resultsCursor, data);
}
uiPanel.setFittedParameterCount(m_fittedParameterCount); //TODO kind of strange since I got that info from uiPanel earlier... This s/b reset(true) or something Also, it doesn't really do anything in uiPanel
long elapsed = System.nanoTime() - start;
System.out.println("nanoseconds " + elapsed);
}
/**
* Calculates the total number of pixels to fit. Used for
* progress bar.
*
* @param channels
* @param fitAll
* @return
*/
private int totalPixelCount(int x, int y, int channels, boolean fitAll) {
int count = x * y;
if (fitAll) {
count *= channels;
}
return count;
}
/**
* Calculates an array of channel indices to iterate over.
*
* @param channel
* @param channels
* @param visibleFit
* @param fitAll
* @return
*/
private int[] channelIndexArray(int channel, int channels, boolean visibleFit, boolean fitAll) {
int returnValue[] = { };
if (fitAll) {
returnValue = new int[visibleFit ? channels - 1 : channels];
int i = 0;
for (int c = 0; c < channels; ++c) {
// skip visible; already processed
if (c != channel || !visibleFit) {
returnValue[i++] = c;
}
}
}
else if (!visibleFit) {
// single channel, not processed yet
returnValue = new int[1];
returnValue[0] = channel;
}
return returnValue;
}
private double getData(LocalizableByDimCursor<T> cursor, int channel, int x, int y, int bin) {
int dim[];
if (m_hasChannels) {
dim = new int[] { x, y, bin, channel };
}
else {
dim = new int[] { x, y, bin };
}
cursor.moveTo(dim);
return cursor.getType().getRealFloat();
}
/**
* Helper routine to create imglib.Image to store fitted results.
*
* @param width
* @param height
* @param components
* @return
*/
private Image<DoubleType> makeImage(int channels, int width, int height, int parameters) {
Image<DoubleType> image = null;
// create image object
int dim[] = { width, height, channels, parameters }; //TODO when we keep chi square in image ++parameters };
image = new ImageFactory<DoubleType>(new DoubleType(), new PlanarContainerFactory()).createImage(dim, "Fitted");
// initialize image
Cursor<DoubleType> cursor = image.createCursor();
while (cursor.hasNext()) {
cursor.fwd();
cursor.getType().set(Double.NaN);
}
return image;
}
private double[] getFittedParams(LocalizableByDimCursor<DoubleType> cursor, int channel, int x, int y, int count) {
double params[] = new double[count];
int position[] = new int[4];
position[0] = x;
position[1] = y;
position[2] = channel;
for (int i = 0; i < count; ++i) {
position[3] = i;
cursor.setPosition(position);
params[i] = cursor.getType().getRealDouble();
}
return params;
}
private void setFittedParamsFromData(LocalizableByDimCursor<DoubleType> cursor, ICurveFitData dataArray[]) {
int x, y;
double[] params;
for (ICurveFitData data : dataArray) {
setFittedParams(cursor, data.getChannel(), data.getX(), data.getY(), data.getParams());
}
}
private void setFittedParams(LocalizableByDimCursor<DoubleType> cursor, int channel, int x, int y, double[] params) {
int position[] = new int[4];
position[0] = x;
position[1] = y;
position[2] = channel;
for (int i = 0; i < params.length; ++i) {
position[3] = i;
cursor.setPosition(position);
cursor.getType().set(params[i]);
}
}
private void cancelImageFit() {
m_fittedImage = null;
m_fittedParameterCount = 0;
}
/**
* Visibly processes a batch of pixels.
*
* @param dataColorizer automatically sets colorization range and updates colorized image
* @param height passed in to fix a vertical orientation problem
* @channel current channel
* @param data list of data corresponding to pixels to be fitted
* @param pixels parallel list of rectangles with which to draw the fitted pixel
*/
void colorizePixels(DataColorizer dataColorizer, int height, int channel, ICurveFitData data[], ChunkyPixel pixels[]) {
// draw as you go; 'chunky' pixels get smaller as the overall fit progresses
for (int i = 0; i < pixels.length; ++i) {
ChunkyPixel pixel = pixels[i];
double lifetime = data[i].getParams()[1];
//TODO debugging:
//if (lifetime > 2 * m_param[1]) {
// System.out.println("BAD FIT??? x " + pixel.getX() + " y " + pixel.getY() + " fitted lifetime " + lifetime);
//}
//TODO BUG:
// With the table as is, you can get
// x y w h
// 12 15 2 1
// 14 15 2 1
// all within the same drawing cycle.
// So it looks like a 4x1 slice gets drawn (it
// is composed of two adjacent 2x1 slices with
// potentially two different colors).
//if (pixel.getWidth() == 2) {
// System.out.println("x " + pixel.getX() + " y " + pixel.getY() + " w " + pixel.getWidth() + " h " + pixel.getHeight());
//}
//System.out.println("w " + pixel.getWidth() + " h " + pixel.getHeight());
//System.out.println("lifetime is " + lifetime);
//Color color = lifetimeColorMap(MAXIMUM_LIFETIME, lifetime);
//imageProcessor.setColor(color);
boolean firstTime = true;
for (int x = pixel.getX(); x < pixel.getX() + pixel.getWidth(); ++x) {
for (int y = pixel.getY(); y < pixel.getY() + pixel.getHeight(); ++y) {
if (wantFitted(channel, x, y)) {
// (flip vertically)
dataColorizer.setData(firstTime, x, height - y - 1 , lifetime);
firstTime = false;
}
}
}
}
dataColorizer.update();
}
/**
* Checks criterion for whether this pixel needs to get fitted or drawn.
*
* @param channel
* @param x
* @param y
* @return whether to include or ignore this pixel
*/
boolean wantFitted(int channel, int x, int y) {
return (aboveThreshold(channel, x, y) & isInROIs(x, y));
}
/**
* Checks whether a given pixel is above threshold photon count value.
*
* @param channel
* @param x
* @param y
* @return whether above threshold
*/
boolean aboveThreshold(int channel, int x, int y) {
return (m_threshold <= m_grayScaleImage.getPixel(channel, x, m_height - y - 1));
}
/**
* Checks whether a given pixel is included in ROIs. If no ROIs are
* selected then all pixels are included.
*
* @param x
* @param y
* @return whether or not included in ROIs
*/
boolean isInROIs(int x, int y) {
Roi[] rois = getRois();
if (0 < rois.length) {
for (Roi roi: rois) {
if (roi.contains(x, y)) {
return true;
}
}
return false;
}
else {
return true;
}
}
/**
* Gets a list of ROIs (may be empty).
*
* @return array of ROIs.
*/
private Roi[] getRois() {
Roi[] rois = {};
RoiManager manager = RoiManager.getInstance();
if (null != manager) {
rois = manager.getRoisAsArray();
}
return rois;
}
/**
* Colorizes a given lifetime value.
*
* Note this is much cruder than the DataColorizer that is
* used in fitEachPixel.
*
* @param max
* @param lifetime
* @return
*/
//TODO make consistent with fitEachPixel's DataColorizer
private Color lifetimeColorMap(double max, double lifetime) {
Color returnColor = Color.BLACK;
if (lifetime > 0.0) {
if (lifetime < max/2.0) {
returnColor = interpolateColor(Color.BLUE, Color.GREEN, 2.0 * lifetime / max);
}
else if (lifetime < max) {
returnColor = interpolateColor(Color.GREEN, Color.RED, 2.0 * (lifetime - max / 2.0) / max);
}
else returnColor = Color.RED;
}
return returnColor;
}
/**
* Interpolates between two colors based on a blend factor.
*
* @param start color
* @param end color
* @param blend factor
* @return interpolated color
*/
private Color interpolateColor(Color start, Color end, double blend) {
int startRed = start.getRed();
int startGreen = start.getGreen();
int startBlue = start.getBlue();
int endRed = end.getRed();
int endGreen = end.getGreen();
int endBlue = end.getBlue();
int red = interpolateColorComponent(startRed, endRed, blend);
int green = interpolateColorComponent(startGreen, endGreen, blend);
int blue = interpolateColorComponent(startBlue, endBlue, blend);
return new Color(red, green, blue);
}
/**
* Interpolates a single RGB component between two values based on
* a blend factor.
*
* @param start component value
* @param end component value
* @param blend factor
* @return interpolated component value
*/
private int interpolateColorComponent(int start, int end, double blend) {
return (int)(blend * (end - start) + start);
}
/*
* Gets the appropriate curve fitter for the current fit.
*
* @param uiPanel has curve fitter selection
*/
private ICurveFitter getCurveFitter(IUserInterfacePanel uiPanel) {
ICurveFitter curveFitter = null;
switch (uiPanel.getAlgorithm()) {
case JAOLHO:
curveFitter = new JaolhoCurveFitter();
break;
/* case AKUTAN:
curveFitter = new AkutanCurveFitter();
break; */
case BARBER_RLD:
curveFitter = new GrayCurveFitter(0);
break;
case BARBER_LMA:
curveFitter = new GrayCurveFitter(1);
break;
case MARKWARDT:
curveFitter = new MarkwardtCurveFitter();
break;
case BARBER2_RLD:
curveFitter = new GrayNRCurveFitter(0);
break;
case BARBER2_LMA:
curveFitter = new GrayNRCurveFitter(1);
break;
case SLIMCURVE_RLD:
curveFitter = new SLIMCurveFitter(SLIMCurveFitter.AlgorithmType.RLD);
break;
case SLIMCURVE_LMA:
curveFitter = new SLIMCurveFitter(SLIMCurveFitter.AlgorithmType.LMA);
break;
}
ICurveFitter.FitFunction fitFunction = null;
switch (uiPanel.getFunction()) {
case SINGLE_EXPONENTIAL:
fitFunction = ICurveFitter.FitFunction.SINGLE_EXPONENTIAL;
break;
case DOUBLE_EXPONENTIAL:
fitFunction = ICurveFitter.FitFunction.DOUBLE_EXPONENTIAL;
break;
case TRIPLE_EXPONENTIAL:
fitFunction = ICurveFitter.FitFunction.TRIPLE_EXPONENTIAL;
break;
case STRETCHED_EXPONENTIAL:
fitFunction = ICurveFitter.FitFunction.STRETCHED_EXPONENTIAL;
break;
}
curveFitter.setFitFunction(fitFunction);
curveFitter.setXInc(m_timeRange);
curveFitter.setFree(uiPanel.getFree());
return curveFitter;
}
/*
* Helper function for the fit. Shows the decay curve.
*
* @param dataArray array of fitted data
*/
private void showDecayGraph(final IUserInterfacePanel uiPanel, ICurveFitData dataArray[]) {
if (0 < dataArray.length) {
//TODO need to be able to examine any fitted pixel; for now just show the first. // was last
DecayGraph decayGraph = new DecayGraph(m_startBin, m_stopBin, m_timeBins, m_timeRange, dataArray[0]); //dataArray.length - 1]);
decayGraph.setStartStopListener(
new IStartStopListener() {
public void setStartStop(int start, int stop) {
uiPanel.setStart(start);
uiPanel.setStop(stop);
}
}
);
JFrame frame = decayGraph.getFrame();
frame.setLocationRelativeTo(uiPanel.getFrame());
frame.setVisible(true);
}
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
5f0d06c3530d5ef85a146522f60095137541e70f | ed5c0344b3f97c3000d3de6837a1746816cfb285 | /src/labs/InStack.java | d45924eea2cd57f61001e820b5b8e1294efe7151 | [] | no_license | AlexRutkas/LAB4 | 9557eccef40e6122cb5999b6918ee144c06b5b46 | 153f4fef08e5ec29e4e63ddfa7aadd14ad12e239 | refs/heads/master | 2021-05-24T09:59:55.497816 | 2020-04-06T13:44:51 | 2020-04-06T13:44:51 | 253,508,893 | 0 | 0 | null | 2020-04-19T13:59:44 | 2020-04-06T13:40:00 | Java | UTF-8 | Java | false | false | 113 | java | /* package labs;
interface InStack<E> {
boolean empty();
E peek();
E pop();
E push(E value);
}*/ | [
"19fi.o.rutkas@std.npu.edu.ua"
] | 19fi.o.rutkas@std.npu.edu.ua |
7d09b821b080183067d41b0100df77f95c901d3d | da0cd683d55a0b455a3bc40fa9591a09cf26fc48 | /compound/duck/RedHeadDuck.java | eb63f479a3ca17584da439d32317764a3ebf9736 | [] | no_license | zzbb1199/HeadFirst | 5916d340cedfd435722f76c0d72bb1362b57e8bc | 94663c586e098b7f4175cbc8c6efc45ae00fbe3f | refs/heads/master | 2020-04-05T06:19:40.593678 | 2018-11-22T14:16:59 | 2018-11-22T14:16:59 | 156,634,040 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 632 | java | package compound.duck;
public class RedHeadDuck implements Quackable {
private Observable observable;
public RedHeadDuck(){
observable = new Observable(this);
}
@Override
public void quack() {
System.out.println("Quack");
notifyObservers();
}
@Override
public void registerObserver(Observer observer) {
observable.registerObserver(observer);
}
@Override
public void removeObserver(Observer observer) {
observable.removeObserver(observer);
}
@Override
public void notifyObservers() {
observable.notifyObservers();
}
}
| [
"2855892305@qq.com"
] | 2855892305@qq.com |
a8a0ce42c4694cd43f1f663c5e3e537a46a0b49f | 89539b655545a19d3bb71b4716957c6085ebcbdd | /PandoraJourney-app/src/main/java/lt/egzaminas/Repository/InstitucijaRepo.java | ae8446661163e2d60aa9e50170cd006a8b232a0b | [] | no_license | PandoraJourney/app2 | 7d521dd970e3f7978eec0b3890222ea8b388acd1 | 8def782aaf371cdc9bbbadbecde581e40321a77b | refs/heads/master | 2021-09-09T18:47:21.060907 | 2018-03-19T00:11:58 | 2018-03-19T00:11:58 | 125,728,241 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 559 | java | package lt.egzaminas.Repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import lt.egzaminas.Entity.*;
@Repository
public interface InstitucijaRepo extends JpaRepository<Institucija, Long> {
//Ieskociau by id, bet neranda to attributo, nes cia daug instituciju istrins
//zodizu cia tik laiko biski daugiau reikejo :) ir gitt'a ismok :/
Institucija findDistinctInstitucijaByPavadinimas(String inst);
void deleteByPavadinimas(String Inst);
Institucija findByPa(Long id);
}
| [
"juozas.adamonis85@gmail.com"
] | juozas.adamonis85@gmail.com |
90a7b4433edf73ecb20863146e9fb42d85b6588f | 7d7313973524e3b833950383fa5267f108477b29 | /apiservice/src/main/java/com/openexpense/dto/OeResult.java | e7378cf10d34ec08acb01d7d524b09e185e9f107 | [] | no_license | OEADMIN/OE | 6a28602495e6270027cfd03616be6745ae4fb0b8 | fe92374de6442fe4d8d6e09288838847b732d8a7 | refs/heads/master | 2021-01-19T04:05:20.963220 | 2016-08-02T07:03:47 | 2016-08-02T07:03:47 | 62,234,091 | 6 | 2 | null | null | null | null | UTF-8 | Java | false | false | 2,966 | java | package com.openexpense.dto;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import java.util.ArrayList;
import java.util.List;
/**服务返回类型
*2016/07/06.
*@author xjouyi@163.com
*/
public class OeResult {
/**服务类型定义
*2016/07/06.
*@author xjouyi@163.com
*/
public enum Type {
/**成功 success*/
success("success"),
/**失败 fail*/
fail("fail"),
/**异常 error*/
error("error");
private String name;
Type(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
private OeResult.Type type;
private String code;
private List<Object> data = null;
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public List<Object> getData(){
return data;
}
private OeResult(){
}
/**根据类型初始化OeResult对象
*@param type OeResult.Type 类型
*/
public OeResult(OeResult.Type type){
this.type = type;
}
/**根据类型和代码初始化OeResult对象
*@param type OeResult.Type 类型
*@param code string 代码
*/
public OeResult(OeResult.Type type,String code){
this.type = type;
this.code = code;
}
public OeResult(OeResult.Type type,Object object){
this.type = type;
this.data = new ArrayList<>();
this.data.add(object);
}
/**获取返回成功对象
*@param result Object 成功后返回数据
*@return OeResult 返回成功对象,{type:success,data:[{}]}
*/
public static OeResult getSuccessResult(Object result){
OeResult oeResult = new OeResult(Type.success);
oeResult.data = new ArrayList<>();
oeResult.data.add(result);
return oeResult;
}
/**获取返回失败对象
*@param error Object 返回失败代码
*@return OeResult 返回失败对象,{type:success,code:xxxx}
*/
public static OeResult getFailResult(OeError error){
return new OeResult(Type.fail,error);
}
public static OeResult getDataVaildResult(BindingResult bindingResult){
OeResult oeResult = new OeResult(Type.fail,"");
oeResult.data = new ArrayList<>();
for (FieldError error : bindingResult.getFieldErrors()) {
oeResult.data.add(new OeError(error));
}
return oeResult;
}
/**获取返回错误对象
*@param code Object 返回错误代码
*@return OeResult 返回错误对象,{type:success,code:xxxx}
*/
public static OeResult getErrorResult(String code){
return new OeResult(Type.error,code);
}
}
| [
"xjouyi@163.com"
] | xjouyi@163.com |
15c5926bade6762e6c56aac59be4a514ea989a43 | 670ee1456ffcb50ae6c1e54e27a4b156ed6a5542 | /src/main/java/com/my/lei/test/think_in_java/interfaces/RandomDoubleAdapter.java | 8285457d0b7250e6d916f0e6185a43be401e214e | [] | no_license | YourShadow555/NewJourney | 353f260f1d127be94e5506e0ff258270a03045cd | 8fed6da7796eb62d29618b2dd49d67270bb288dd | refs/heads/master | 2020-04-08T11:13:50.616889 | 2018-11-27T08:02:35 | 2018-11-27T08:02:35 | 159,298,051 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 871 | java | package com.my.lei.test.think_in_java.interfaces;
import java.io.IOException;
import java.nio.CharBuffer;
import java.util.Scanner;
public class RandomDoubleAdapter extends RandomDoubles implements Readable {
private int count;
public RandomDoubleAdapter(int count) {
this.count = count;
}
@Override
public int read(CharBuffer cb) throws IOException {
if (count-- == 0) {
return -1;
}
//why must add " " why " " is necessary
String s = Double.toString(next()) + " ";
System.out.println("test::::>"+s);
cb.append(s);
return s.length();
}
public static void main(String[] args) {
Scanner scanner = new Scanner(new RandomDoubleAdapter(7));
while (scanner.hasNextDouble()) {
System.out.println(scanner.nextDouble());
}
}
}
| [
"1050440418@qq.com"
] | 1050440418@qq.com |
923599d768c1f7e6d9e9574612952bb34922a0c4 | 17e13b0088a5400becf1f3e4fd3366f6f526bde1 | /Ghidra/Processors/MIPS/src/main/java/ghidra/app/plugin/core/analysis/MipsAddressAnalyzer.java | c1b5c4dedc780e9be2a2e737f33260d927bb11a5 | [
"Apache-2.0",
"GPL-1.0-or-later",
"GPL-3.0-only",
"LicenseRef-scancode-public-domain",
"LGPL-2.1-only",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | nterry/ghidra | 1988d073fe219b7fbe96d034a0ebd4c398964396 | c004a11c6b823ce376709b52557728b8f49c1100 | refs/heads/master | 2020-05-21T02:19:23.102492 | 2019-05-02T20:34:58 | 2019-05-02T20:34:58 | 185,875,467 | 1 | 0 | Apache-2.0 | 2019-05-09T21:40:46 | 2019-05-09T21:40:46 | null | UTF-8 | Java | false | false | 25,421 | java | /* ###
* IP: GHIDRA
*
* 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 ghidra.app.plugin.core.analysis;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;
import ghidra.app.cmd.function.CreateFunctionCmd;
import ghidra.app.plugin.core.disassembler.AddressTable;
import ghidra.app.util.importer.MessageLog;
import ghidra.framework.options.Options;
import ghidra.program.disassemble.Disassembler;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
import ghidra.program.model.scalar.Scalar;
import ghidra.program.model.symbol.*;
import ghidra.program.util.*;
import ghidra.util.Msg;
import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
public class MipsAddressAnalyzer extends ConstantPropagationAnalyzer {
private static final int MAX_UNIQUE_GP_SYMBOLS = 50;
private final static String OPTION_NAME_SWITCH_TABLE = "Attempt to recover switch tables";
private final static String OPTION_DESCRIPTION_SWITCH_TABLE = "";
private static final String OPTION_NAME_MARK_DUAL_INSTRUCTION =
"Mark dual instruction references";
private static final String OPTION_DESCRIPTION_MARK_DUAL_INSTRUCTION =
"Turn on to mark all potential dual instruction refs," + "\n" + "(lis - addi/orri/subi)" +
"\n" + " even if they are not seen to be used as a reference.";
private static final String OPTION_NAME_ASSUME_T9_ENTRY = "Assume T9 set to Function entry";
private static final String OPTION_DESCRIPTION_ASSUME_T9_ENTRY =
"Turn on to assume that T9 is set to the entry address of a function when unset T9 register usage encountered";
private static final String OPTION_NAME_RECOVER_GP = "Recover global GP register writes";
private static final String OPTION_DESCRIPTION_RECOVER_GP =
"Discover writes to the global GP register and assume as constant at the start of functions if only one value has been discovered.";
private static final boolean OPTION_DEFAULT_SWITCH_TABLE = false;
private static final boolean OPTION_DEFAULT_MARK_DUAL_INSTRUCTION = false;
private static final boolean OPTION_DEFAULT_ASSUME_T9_ENTRY = true;
private static final boolean OPTION_DEFAULT_RECOVER_GP = true;
private boolean trySwitchTables = OPTION_DEFAULT_SWITCH_TABLE;
private boolean markupDualInstructionOption = OPTION_DEFAULT_MARK_DUAL_INSTRUCTION;
private boolean assumeT9EntryAddress = OPTION_DEFAULT_ASSUME_T9_ENTRY;
private boolean discoverGlobalGPSetting = OPTION_DEFAULT_RECOVER_GP;
private String[] strLoadStore =
{ "addiu", "daddiu", "lw", "_lw", "sw", "_sw", "sh", "_sh", "sd", "_sd", "lbu", "lhu" };
private HashSet<String> targetLoadStore = new HashSet<String>(Arrays.asList(strLoadStore));
private Register t9;
private Register gp;
private Register rareg;
private Register isamode;
private Register ismbit;
private Address gp_assumption_value = null;
private final static String PROCESSOR_NAME = "MIPS";
public MipsAddressAnalyzer() {
super(PROCESSOR_NAME);
}
@Override
public boolean canAnalyze(Program program) {
boolean canAnalyze = program.getLanguage().getProcessor().equals(
Processor.findOrPossiblyCreateProcessor(PROCESSOR_NAME));
if (!canAnalyze) {
return false;
}
t9 = program.getRegister("t9");
gp = program.getRegister("gp");
rareg = program.getRegister("ra");
isamode = program.getProgramContext().getRegister("ISA_MODE");
ismbit = program.getProgramContext().getRegister("ISAModeSwitch");
return true;
}
@Override
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
throws CancelledException {
gp_assumption_value = null;
// check for the _gp symbol to see what the global gp value should be
checkForGlobalGP(program, set, monitor);
return super.added(program, set, monitor, log);
}
/**
* Check for a global GP register symbol or discovered symbol
* @param set
*/
private void checkForGlobalGP(Program program, AddressSetView set, TaskMonitor monitor) {
// don't want to check for it
if (!discoverGlobalGPSetting) {
return;
}
// TODO: Use gp_value provided by MIPS .reginfo or dynamic attributes - check for Elf loader symbol
// see MIPS_ElfExtension.MIPS_GP_VALUE_SYMBOL
Symbol symbol = SymbolUtilities.getLabelOrFunctionSymbol(program, "_mips_gp_value",
err -> Msg.error(this, err));
if (symbol != null) {
gp_assumption_value = symbol.getAddress();
return;
}
if (set != null && !set.isEmpty()) {
// if GP is already Set, don't go looking for a value.
AddressRangeIterator registerValueAddressRanges =
program.getProgramContext().getRegisterValueAddressRanges(gp);
while (registerValueAddressRanges.hasNext()) {
// but set it so we know if the value we are assuming actually changes
AddressRange next = registerValueAddressRanges.next();
if (set.contains(next.getMinAddress(), next.getMaxAddress())) {
RegisterValue registerValue =
program.getProgramContext().getRegisterValue(gp, next.getMinAddress());
gp_assumption_value = next.getMinAddress().getNewAddress(
registerValue.getUnsignedValue().longValue());
return;
}
}
}
// look for the global _gp variable set by ELF binaries
symbol =
SymbolUtilities.getLabelOrFunctionSymbol(program, "_gp", err -> Msg.error(this, err));
if (symbol == null) {
symbol = SymbolUtilities.getLabelOrFunctionSymbol(program, "_GP",
err -> Msg.error(this, err));
}
if (symbol != null) {
gp_assumption_value = symbol.getAddress();
}
// look for any setting of _gp_# variables
Symbol s1 =
SymbolUtilities.getLabelOrFunctionSymbol(program, "_gp_1", err -> Msg.error(this, err));
if (s1 == null) {
return;
}
// if we found a _gp symbol we set, and there is a global symbol, something is amiss
if (gp_assumption_value != null && s1.getAddress().equals(gp_assumption_value)) {
gp_assumption_value = null;
return;
}
Symbol s2 =
SymbolUtilities.getLabelOrFunctionSymbol(program, "_gp_2", err -> Msg.error(this, err));
if (s2 == null) {
// if there is only 1, assume can use the value for now
gp_assumption_value = s1.getAddress();
}
return;
}
public Symbol setGPSymbol(Program program, Address toAddr) {
int index = 1;
// Only try max times. More than max settings of GP is overkill
while (index < MAX_UNIQUE_GP_SYMBOLS) {
try {
String symname = "_gp_" + index++;
// check if it already exists
Symbol existingSymbol = SymbolUtilities.getLabelOrFunctionSymbol(program, symname,
err -> { /* ignore multiple symbols, if even one exists we need to skip if it has a different address */ } );
if (existingSymbol != null) {
if (existingSymbol.getAddress().equals(toAddr)) {
return existingSymbol;
}
continue; // can't use this one, look for the next free gp_<x> symbol
}
Symbol createSymbol =
program.getSymbolTable().createLabel(toAddr, symname, SourceType.ANALYSIS);
return createSymbol;
}
catch (InvalidInputException e) {
break;
}
}
return null;
}
@Override
public AddressSetView flowConstants(final Program program, Address flowStart,
AddressSetView flowSet, final SymbolicPropogator symEval, final TaskMonitor monitor)
throws CancelledException {
// get the function body
final Function func = program.getFunctionManager().getFunctionContaining(flowStart);
final AddressSet coveredSet = new AddressSet();
if (func != null) {
flowStart = func.getEntryPoint();
if (gp_assumption_value != null) {
ProgramContext programContext = program.getProgramContext();
RegisterValue gpVal = programContext.getRegisterValue(gp, flowStart);
if (gpVal == null || !gpVal.hasValue()) {
gpVal =
new RegisterValue(gp, BigInteger.valueOf(gp_assumption_value.getOffset()));
try {
program.getProgramContext().setRegisterValue(func.getEntryPoint(),
func.getEntryPoint(), gpVal);
}
catch (ContextChangeException e) {
throw new AssertException("unexpected", e); // only happens for context register
}
}
}
}
// follow all flows building up context
// use context to fill out addresses on certain instructions
ContextEvaluator eval = new ConstantPropagationContextEvaluator(trustWriteMemOption) {
private boolean mustStopNow = false; // if something discovered in processing, mustStop flag
@Override
public boolean evaluateContextBefore(VarnodeContext context, Instruction instr) {
return mustStopNow;
}
@Override
public boolean evaluateContext(VarnodeContext context, Instruction instr) {
if (markupDualInstructionOption) {
markupDualInstructions(context, instr);
}
// if ra is a constant and is set right after this, this is a call
// this was copylefted from the arm analyzer
Varnode raVal = context.getRegisterVarnodeValue(rareg);
if (raVal != null) {
if (raVal.isConstant()) {
long target = raVal.getAddress().getOffset();
Address addr = instr.getMaxAddress();
if (target == (addr.getOffset() + 1) && !instr.getFlowType().isCall()) {
instr.setFlowOverride(FlowOverride.CALL);
// need to trigger disassembly below! if not already
MipsExtDisassembly(program, instr, context, addr.add(1), monitor);
// need to trigger re-function creation!
Function f = program.getFunctionManager().getFunctionContaining(
instr.getMinAddress());
if (f != null) {
try {
CreateFunctionCmd.fixupFunctionBody(program, f, monitor);
}
catch (CancelledException e) {
return true;
}
//AutoAnalysisManager.getAnalysisManager(program).functionDefined(
// func.getBody());
}
}
}
}
// check if the GP register is set
FlowType flowType = instr.getFlowType();
if (discoverGlobalGPSetting && (flowType.isCall() || flowType.isTerminal())) {
// check for GP set
RegisterValue registerValue = context.getRegisterValue(gp);
if (registerValue != null) {
BigInteger value = registerValue.getUnsignedValue();
long unsignedValue = value.longValue();
if (gp_assumption_value == null ||
!(unsignedValue == gp_assumption_value.getOffset())) {
synchronized (gp) {
Address gpRefAddr =
instr.getMinAddress().getNewAddress(unsignedValue);
setGPSymbol(program, gpRefAddr);
Address lastSetAddr = context.getLastSetLocation(gp, value);
Instruction lastSetInstr = instr;
if (lastSetAddr != null) {
Instruction instructionAt =
program.getListing().getInstructionContaining(lastSetAddr);
if (instructionAt != null) {
lastSetInstr = instructionAt;
}
}
symEval.makeReference(context, lastSetInstr, -1,
instr.getMinAddress().getAddressSpace().getBaseSpaceID(),
unsignedValue, 1, RefType.DATA, PcodeOp.UNIMPLEMENTED, true,
monitor);
if (gp_assumption_value == null) {
program.getBookmarkManager().setBookmark(
lastSetInstr.getMinAddress(), BookmarkType.WARNING,
"GP Global Register Set",
"Global GP Register is set here.");
}
if (gp_assumption_value != null &&
!gp_assumption_value.equals(gpRefAddr)) {
gp_assumption_value = null;
}
else {
gp_assumption_value = gpRefAddr;
}
}
}
}
}
return mustStopNow;
}
private void markupDualInstructions(VarnodeContext context, Instruction instr) {
String mnemonic = instr.getMnemonicString();
if (targetLoadStore.contains(mnemonic)) {
Register reg = instr.getRegister(0);
if (reg != null) {
BigInteger val = context.getValue(reg, false);
if (val != null) {
long lval = val.longValue();
Address refAddr = instr.getMinAddress().getNewAddress(lval);
if ((lval > 4096 || lval < 0) && lval != 0xffff &&
program.getMemory().contains(refAddr)) {
int opCheck = 0;
if (instr.getOperandReferences(opCheck).length == 0) {
instr.addOperandReference(opCheck, refAddr, RefType.DATA,
SourceType.ANALYSIS);
}
}
}
}
}
}
@Override
public boolean evaluateReference(VarnodeContext context, Instruction instr, int pcodeop,
Address address, int size, RefType refType) {
Address addr = address;
//if (instr.getFlowType().isJump() && !instr.getPrototype().hasDelaySlots()) {
// if this isn't straight code (thunk computation), let someone else lay down the reference
// return !symEval.encounteredBranch();
//}
if (instr.getMnemonicString().endsWith("lui")) {
return false;
}
if ((refType.isJump() || refType.isCall()) & refType.isComputed()) {
//if (refType.isJump() || refType.isCall()) {
addr = MipsExtDisassembly(program, instr, context, address, monitor);
//addr = flowISA(program, instr, context, address);
if (addr == null) {
addr = address;
}
}
// if this is a call, some processors use the register value
// used in the call for PIC calculations
if (refType.isCall()) {
// set the called function to have a constant value for this register
// WARNING: This might not always be the case, if called directly or with a different register
// But then it won't matter, because the function won't depend on the registers value.
if (instr.getFlowType().isComputed()) {
Register reg = instr.getRegister(0);
if (reg != null && t9.equals(reg) && assumeT9EntryAddress) {
BigInteger val = context.getValue(reg, false);
if (val != null) {
try {
// clear the register, so it won't be set below this call.
// if it is assumed to be set to the same value, it can lead
// to incorrect re-use of the value (non-returning functions)
context.clearRegister(reg);
// need to add the reference here, register operand will no longer have a value
instr.addOperandReference(0, addr, refType, SourceType.ANALYSIS);
// set the register value on the target address
ProgramContext progContext = program.getProgramContext();
if (progContext.getValue(reg, addr, false) == null) {
progContext.setValue(reg, addr, addr, val);
// if we do this, probably need to restart code analysis with function body,
AutoAnalysisManager amgr =
AutoAnalysisManager.getAnalysisManager(program);
amgr.codeDefined(new AddressSet(addr));
}
}
catch (ContextChangeException e) {
// ignore context change
}
}
}
}
}
return super.evaluateReference(context, instr, pcodeop, address, size, refType);
}
@Override
public boolean evaluateDestination(VarnodeContext context, Instruction instruction) {
FlowType flowtype = instruction.getFlowType();
if (!flowtype.isJump()) {
return false;
}
if (trySwitchTables) {
String mnemonic = instruction.getMnemonicString();
if (mnemonic.equals("jr")) {
fixJumpTable(program, instruction, monitor);
}
}
return false;
}
@Override
public Long unknownValue(VarnodeContext context, Instruction instruction,
Varnode node) {
if (assumeT9EntryAddress && node.isRegister() &&
context.getRegisterVarnode(t9).contains(node.getAddress())) {
// if get a T9 Register, need to stop evaluating
// if can't find the beginning of the function, then must stop and assume something else
// will pick it up.
if (func != null) {
Address funcAddr = func.getEntryPoint();
Long value = new Long(funcAddr.getOffset());
try {
ProgramContext progContext = program.getProgramContext();
// if T9 hasn't already been set
if (progContext.getValue(t9, funcAddr, false) == null) {
progContext.setRegisterValue(funcAddr, funcAddr,
new RegisterValue(t9, BigInteger.valueOf(value)));
// if we do this, need to restart code analysis with function body,
// since this is not ready.
AutoAnalysisManager amgr =
AutoAnalysisManager.getAnalysisManager(program);
coveredSet.add(func.getBody());
amgr.codeDefined(coveredSet);
}
}
catch (ContextChangeException e) {
throw new AssertException("Unexpected Exception", e);
}
}
else {
// If there is no function, kick the can to an analyzer that waits for functions
// to be created and sets the T9...
}
mustStopNow = true;
}
return null;
}
};
AddressSet resultSet = symEval.flowConstants(flowStart, null, eval, true, monitor);
// Add in any addresses we should assume got covered
// These addresses are put on because we had to stop analysis due to an unknown register value
resultSet.add(coveredSet);
return resultSet;
}
Address MipsExtDisassembly(Program program, Instruction instruction, VarnodeContext context,
Address target, TaskMonitor monitor) {
if (target == null) {
return null;
}
Address addr = flowISA(program, instruction, context, target);
if (addr != null) {
MemoryBlock block = program.getMemory().getBlock(addr);
if (block == null || !block.isExecute() || !block.isInitialized() ||
block.getName().equals("EXTERNAL")) {
return addr;
}
Disassembler dis = Disassembler.getDisassembler(program, monitor, null);
AddressSet disassembleAddrs = dis.disassemble(addr, null);
AutoAnalysisManager.getAnalysisManager(program).codeDefined(disassembleAddrs);
}
return addr;
}
Address flowISA(Program program, Instruction instruction, VarnodeContext context,
Address target) {
if (target == null) {
return null;
}
Address addr = instruction.getMinAddress().getNewAddress(target.getOffset() & 0xfffffffe);
Listing listing = program.getListing();
if (isamode != null && listing.getUndefinedDataAt(addr) != null) {
boolean inM16Mode = false;
RegisterValue curvalue = context.getRegisterValue(isamode, instruction.getMinAddress());
if (curvalue != null && curvalue.hasValue()) {
inM16Mode = (curvalue.getUnsignedValue().intValue() == 1);
}
// if the ISM bit is set, that trumps any mode we are tracking
RegisterValue tbvalue = context.getRegisterValue(ismbit);
if (tbvalue != null && tbvalue.hasValue()) {
inM16Mode = (tbvalue.getUnsignedValue().intValue() == 1);
}
BigInteger m16ModeValue = BigInteger.valueOf(inM16Mode ? 1 : 0);
try {
program.getProgramContext().setValue(isamode, addr, addr, m16ModeValue);
}
catch (ContextChangeException e) {
throw new AssertException("Unexpected Exception", e);
}
return addr;
}
// instruction already there
return null;
}
/**
* @param program
* @param startInstr
* @param monitor
*/
private void fixJumpTable(Program program, Instruction startInstr, TaskMonitor monitor) {
int tableLen = -1;
Address tableAddr = null;
int valueSize = -1;
Register target = null;
// if already has more than one reference from it, assume it has been
// done!
Address addr = startInstr.getMinAddress();
if (checkAlreadyRecovered(program, addr)) {
return;
}
// search backward for:
// sltiu instruction, that is the size of the table
// addiu instruction, the reference there is the table
Instruction curInstr = startInstr;
while (tableLen == -1 || (target != null && tableAddr == null)) {
Address fallAddr = curInstr.getFallFrom();
Instruction prevInstr = null;
if (fallAddr != null) {
prevInstr = program.getListing().getInstructionContaining(fallAddr);
}
if (prevInstr == null) {
ReferenceIterator iter = curInstr.getReferenceIteratorTo();
if (iter.hasNext()) {
Reference ref = iter.next();
if (!ref.getReferenceType().isCall()) {
prevInstr =
program.getListing().getInstructionContaining(ref.getFromAddress());
}
}
}
if (!curInstr.isInDelaySlot() && prevInstr != null &&
prevInstr.getPrototype().hasDelaySlots()) {
prevInstr = prevInstr.getNext();
}
if (prevInstr == null) {
return;
}
if (prevInstr.getMinAddress().compareTo(curInstr.getMinAddress()) >= 0) {
return;
}
curInstr = prevInstr;
// this is the size of the table
if (tableLen == -1 && (curInstr.getMnemonicString().equals("sltiu") ||
curInstr.getMnemonicString().equals("_sltiu"))) {
Scalar scalar = curInstr.getScalar(2);
if (scalar == null) {
return;
}
tableLen = (int) scalar.getUnsignedValue();
if (tableLen > 255 || tableLen < 2) {
return;
}
continue;
}
// this is the table location
// assumes the mips markup has already found the lui/addiu pair
if (tableAddr == null && curInstr.getMnemonicString().equals("addiu")) {
if (target == null || target.equals(curInstr.getRegister(0))) {
Reference[] refs = curInstr.getReferencesFrom();
if (refs == null || refs.length == 0) {
return;
}
tableAddr = refs[0].getToAddress();
}
}
if (tableLen == -1) {
// this is the step of the table
if (valueSize == -1 && (curInstr.getMnemonicString().equals("sll") ||
curInstr.getMnemonicString().equals("_sll"))) {
valueSize = 1 << (int) curInstr.getScalar(2).getUnsignedValue();
}
if (tableAddr == null) {
if (valueSize == -1 && curInstr.getMnemonicString().equals("lw")) {
valueSize = 4;
}
if (curInstr.getMnemonicString().equals("addu")) {
target = curInstr.getRegister(2);
}
}
}
}
if (tableAddr == null) {
return;
}
if (tableLen <= 0) {
return;
}
if (valueSize == -1) {
valueSize = program.getDefaultPointerSize();
}
AddressTable table = AddressTable.getEntry(program, tableAddr, monitor, false, tableLen,
valueSize, 0, AddressTable.MINIMUM_SAFE_ADDRESS, true);
if (table == null) {
table = AddressTable.getEntry(program, tableAddr, monitor, false, 3, valueSize, 0,
AddressTable.MINIMUM_SAFE_ADDRESS, true);
if (table != null) {
Msg.error(this,
"**** MIPS Analyzer: SHOULD be a table of size " + tableLen + " at " +
tableAddr + " got " + table.getNumberAddressEntries() +
" from instruction at " + startInstr.getMinAddress());
}
else {
Msg.error(this, "**** MIPS Analyzer: SHOULD be a table of size " + tableLen +
" at " + tableAddr + " from instruction at " + startInstr.getMinAddress());
return;
}
}
if (tableLen < table.getNumberAddressEntries()) {
table.truncate(tableLen);
}
// We don't do indexes, even if it says it has one. So get rid of it.
if (table.getIndexLength() != 0) {
table = new AddressTable(table.getTopAddress(), table.getTableElements(), null, 0,
valueSize, 0, false);
}
table.createSwitchTable(program, startInstr, 1, false, monitor);
}
private boolean checkAlreadyRecovered(Program program, Address addr) {
int referenceCountFrom = program.getReferenceManager().getReferenceCountFrom(addr);
if (referenceCountFrom > 1) {
return true;
}
Reference[] refs = program.getReferenceManager().getReferencesFrom(addr);
if (refs.length == 1 && !refs[0].getReferenceType().isData()) {
return true;
}
return false;
}
@Override
public void optionsChanged(Options options, Program program) {
super.optionsChanged(options, program);
options.registerOption(OPTION_NAME_SWITCH_TABLE, OPTION_DEFAULT_SWITCH_TABLE, null,
OPTION_DESCRIPTION_SWITCH_TABLE);
options.registerOption(OPTION_NAME_MARK_DUAL_INSTRUCTION,
OPTION_DEFAULT_MARK_DUAL_INSTRUCTION, null, OPTION_DESCRIPTION_MARK_DUAL_INSTRUCTION);
options.registerOption(OPTION_NAME_ASSUME_T9_ENTRY, OPTION_DEFAULT_ASSUME_T9_ENTRY, null,
OPTION_DESCRIPTION_ASSUME_T9_ENTRY);
options.registerOption(OPTION_NAME_ASSUME_T9_ENTRY, OPTION_DEFAULT_ASSUME_T9_ENTRY, null,
OPTION_DESCRIPTION_ASSUME_T9_ENTRY);
options.registerOption(OPTION_NAME_RECOVER_GP, OPTION_DEFAULT_RECOVER_GP, null,
OPTION_DESCRIPTION_RECOVER_GP);
trySwitchTables = options.getBoolean(OPTION_NAME_SWITCH_TABLE, OPTION_DEFAULT_SWITCH_TABLE);
markupDualInstructionOption = options.getBoolean(OPTION_NAME_MARK_DUAL_INSTRUCTION,
OPTION_DEFAULT_MARK_DUAL_INSTRUCTION);
assumeT9EntryAddress =
options.getBoolean(OPTION_NAME_ASSUME_T9_ENTRY, OPTION_DEFAULT_ASSUME_T9_ENTRY);
assumeT9EntryAddress =
options.getBoolean(OPTION_NAME_ASSUME_T9_ENTRY, OPTION_DEFAULT_ASSUME_T9_ENTRY);
discoverGlobalGPSetting =
options.getBoolean(OPTION_NAME_RECOVER_GP, OPTION_DEFAULT_RECOVER_GP);
}
}
| [
"46821332+nsadeveloper789@users.noreply.github.com"
] | 46821332+nsadeveloper789@users.noreply.github.com |
7b6c4643fd6475236166548a6db6d5c14c8bc56b | ae5eb1a38b4d22c82dfd67c86db73592094edc4b | /project224/src/main/java/org/gradle/test/performance/largejavamultiproject/project224/p1120/Production22413.java | ffd4f9df23c78e2acfe3ed7b5e35c82bffa84ebd | [] | no_license | big-guy/largeJavaMultiProject | 405cc7f55301e1fd87cee5878a165ec5d4a071aa | 1cd6a3f9c59e9b13dffa35ad27d911114f253c33 | refs/heads/main | 2023-03-17T10:59:53.226128 | 2021-03-04T01:01:39 | 2021-03-04T01:01:39 | 344,307,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,890 | java | package org.gradle.test.performance.largejavamultiproject.project224.p1120;
public class Production22413 {
private String property0;
public String getProperty0() {
return property0;
}
public void setProperty0(String value) {
property0 = value;
}
private String property1;
public String getProperty1() {
return property1;
}
public void setProperty1(String value) {
property1 = value;
}
private String property2;
public String getProperty2() {
return property2;
}
public void setProperty2(String value) {
property2 = value;
}
private String property3;
public String getProperty3() {
return property3;
}
public void setProperty3(String value) {
property3 = value;
}
private String property4;
public String getProperty4() {
return property4;
}
public void setProperty4(String value) {
property4 = value;
}
private String property5;
public String getProperty5() {
return property5;
}
public void setProperty5(String value) {
property5 = value;
}
private String property6;
public String getProperty6() {
return property6;
}
public void setProperty6(String value) {
property6 = value;
}
private String property7;
public String getProperty7() {
return property7;
}
public void setProperty7(String value) {
property7 = value;
}
private String property8;
public String getProperty8() {
return property8;
}
public void setProperty8(String value) {
property8 = value;
}
private String property9;
public String getProperty9() {
return property9;
}
public void setProperty9(String value) {
property9 = value;
}
} | [
"sterling.greene@gmail.com"
] | sterling.greene@gmail.com |
cf2f2daa8f596384520dc467c53493d5568ede31 | 8ab2b94e35cc8f78d4e9bbfb6287681124068528 | /src/java/com/schlmgt/profile/ClassView.java | d87ebf3a8d628ff3e2df31c73618e2b02ade51bc | [] | no_license | goldtivere/AppSchl | 0ed8b7e6aa0308747155e1dfa0f7da4fe1cd6afe | ae9d65f21260af4461ac7f33d4d95fe8929f8f26 | refs/heads/master | 2020-03-28T01:59:48.922424 | 2018-12-23T22:10:43 | 2018-12-23T22:10:43 | 147,539,932 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,071 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.schlmgt.profile;
import com.schlmgt.dbconn.DbConnectionX;
import com.schlmgt.register.TermModel;
import com.schlmgt.updateSubject.SessionTable;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
/**
*
* @author Gold
*/
@ManagedBean(name = "vaClass")
@ViewScoped
public class ClassView implements Serializable {
private EditStudent edits = new EditStudent();
private List<SubjectModel> sub;
private String currentClass;
private String year;
private String term;
private String classType;
private List<TermModel> terms;
private List<String> years;
private String school;
private String messangerOfTruth;
private String studentid;
private SecondaryModel secModel = new SecondaryModel();
@PostConstruct
public void init() {
try {
FacesContext ctx = FacesContext.getCurrentInstance();
FacesMessage msg;
String stuValue = null;
stuValue = (String) ctx.getExternalContext().getApplicationMap().get("reDet");
SecondaryModel secResult = (SecondaryModel) ctx.getExternalContext().getApplicationMap().get("SecData");
//test for null...
secModel = secResult;
if (secModel != null) {
setStudentid(secModel.getStudentid());
}
if (stuValue != null) {
stuValue = stuValue.replaceAll("\\s", "_");
setSchool(stuValue);
} else {
setMessangerOfTruth("Session Expired for** this Student. Please select student and try again!!");
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, getMessangerOfTruth(), getMessangerOfTruth());
ctx.addMessage(null, msg);
}
sub = testMic();
terms = termDropdown();
years = yearDropdown(getTerm());
} catch (Exception e) {
e.printStackTrace();
}
}
public void onYearChange(String term, String year) throws Exception {
sub = testMic(term, year);
}
public List<SubjectModel> testMic(String term, String year) throws SQLException {
studentCurrentClass();
DbConnectionX dbConnections = new DbConnectionX();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs
= null;
con = dbConnections.mySqlDBconnection();
String studId;
try {
setTerm(term);
setYear(year);
String testguid = "Select * from sessiontable where term=? and grade =? and year=?";
pstmt = con.prepareStatement(testguid);
pstmt.setString(1, term);
pstmt.setString(2, getCurrentClass());
pstmt.setString(3, year);
rs = pstmt.executeQuery();
List<SubjectModel> lst = new ArrayList<>();
while (rs.next()) {
SubjectModel coun = new SubjectModel();
coun.setId(rs.getInt("id"));
coun.setSubject(rs.getString("subject"));
lst.add(coun);
}
return lst;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (!(con == null)) {
con.close();
con = null;
}
if (!(pstmt == null)) {
pstmt.close();
pstmt = null;
}
}
}
public void ontermchange(String term) {
try {
years = yearDropdown(term);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public List<String> yearDropdown(String term) throws Exception {
FacesContext context = FacesContext.getCurrentInstance();
DbConnectionX dbConnections = new DbConnectionX();
Connection con = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
try {
con = dbConnections.mySqlDBconnection();
String query = "SELECT distinct year FROM yearterm where term=?";
pstmt = con.prepareStatement(query);
pstmt.setString(1, term);
rs = pstmt.executeQuery();
//
List<String> lst = new ArrayList<>();
while (rs.next()) {
lst.add(rs.getString("year"));
}
return lst;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (!(con == null)) {
con.close();
con = null;
}
if (!(pstmt == null)) {
pstmt.close();
pstmt = null;
}
}
}
public List<TermModel> termDropdown() throws Exception {
FacesContext context = FacesContext.getCurrentInstance();
DbConnectionX dbConnections = new DbConnectionX();
Connection con = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
try {
con = dbConnections.mySqlDBconnection();
String query = "SELECT * FROM tbterm";
pstmt = con.prepareStatement(query);
rs = pstmt.executeQuery();
//
List<TermModel> lst = new ArrayList<>();
while (rs.next()) {
TermModel coun = new TermModel();
coun.setId(rs.getInt("id"));
coun.setTerm(rs.getString("term"));
//
lst.add(coun);
}
return lst;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (!(con == null)) {
con.close();
con = null;
}
if (!(pstmt == null)) {
pstmt.close();
pstmt = null;
}
}
}
public void studentCurrentClass() {
try {
DbConnectionX dbConnections = new DbConnectionX();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
con = dbConnections.mySqlDBconnection();
String testguid = "Select * from " + getSchool() + "_tbstudentclass where studentid=? and currentclass = ?";
pstmt = con.prepareStatement(testguid);
pstmt.setString(1, getStudentid());
pstmt.setBoolean(2, true);
rs = pstmt.executeQuery();
if (rs.next()) {
setCurrentClass(rs.getString("class"));
setClassType(rs.getString("classtype"));
setTerm(rs.getString("term"));
setYear(rs.getString("year"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public List<SubjectModel> testMic() throws SQLException {
studentCurrentClass();
DbConnectionX dbConnections = new DbConnectionX();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs
= null;
con = dbConnections.mySqlDBconnection();
String studId;
try {
String testguid = "Select * from sessiontable where term=? and grade =? and year=? and isdeleted=?";
pstmt = con.prepareStatement(testguid);
pstmt.setString(1, getTerm());
pstmt.setString(2, getCurrentClass());
pstmt.setString(3, getYear());
pstmt.setBoolean(4, false);
rs = pstmt.executeQuery();
List<SubjectModel> lst = new ArrayList<>();
while (rs.next()) {
SubjectModel coun = new SubjectModel();
coun.setId(rs.getInt("id"));
coun.setSubject(rs.getString("subject"));
lst.add(coun);
}
return lst;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (!(con == null)) {
con.close();
con = null;
}
if (!(pstmt == null)) {
pstmt.close();
pstmt = null;
}
}
}
public List<TermModel> getTerms() {
return terms;
}
public void setTerms(List<TermModel> terms) {
this.terms = terms;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public List<String> getYears() {
return years;
}
public void setYears(List<String> years) {
this.years = years;
}
public String getTerm() {
return term;
}
public void setTerm(String term) {
this.term = term;
}
public String getClassType() {
return classType;
}
public void setClassType(String classType) {
this.classType = classType;
}
public List<SubjectModel> getSub() {
return sub;
}
public void setSub(List<SubjectModel> sub) {
this.sub = sub;
}
public String getCurrentClass() {
return currentClass;
}
public void setCurrentClass(String currentClass) {
this.currentClass = currentClass;
}
public EditStudent getEdits() {
return edits;
}
public void setEdits(EditStudent edits) {
this.edits = edits;
}
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
public String getMessangerOfTruth() {
return messangerOfTruth;
}
public void setMessangerOfTruth(String messangerOfTruth) {
this.messangerOfTruth = messangerOfTruth;
}
public String getStudentid() {
return studentid;
}
public void setStudentid(String studentid) {
this.studentid = studentid;
}
public SecondaryModel getSecModel() {
return secModel;
}
public void setSecModel(SecondaryModel secModel) {
this.secModel = secModel;
}
}
| [
"Gold@Gold.mshome.net"
] | Gold@Gold.mshome.net |
645ae33459161bc8f0793204c7bad418aaf21d3c | dd111e9df631d8efec556c2ee0b0adbef475a5fa | /Sida_prj/src/main/java/com/itwill/sida/controller/ChartController.java | 5e8609ae8ca6d47214cc5cfd744527ff0eb368b1 | [] | no_license | 0chun/1601_itwill_final | 330fa130afa9ed0397fa96f61f45c849fe8523ca | dbf1b3af6fb46a90a00228d79c8c3f72d6795953 | refs/heads/master | 2021-01-13T13:00:18.344648 | 2018-10-18T23:54:08 | 2018-10-18T23:54:08 | 51,743,446 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,571 | java | package com.itwill.sida.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
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 org.springframework.web.bind.annotation.ResponseBody;
import com.itwill.sida.dto.Member;
import com.itwill.sida.dto.MoneyUseResult;
import com.itwill.sida.service.CardService;
import com.itwill.sida.service.MoneyBookService;
@Controller
public class ChartController {
@Autowired
MoneyBookService moneyBookService;
@Autowired
CardService cardService;
@RequestMapping(value="/mainChart_RevenuesPrinter", produces = "application/json; charset=utf-8")
public String mainChart_RevenuesPrinter(HttpSession session){
if ((Member) session.getAttribute("sMember") == null) {
return null;
}
Member member = (Member) session.getAttribute("sMember");
return null;
}
@RequestMapping(value="/mainChart_ConversionPrinter", produces = "application/json; charset=utf-8")
public @ResponseBody MoneyUseResult mainChart_ConversionPrinter(HttpSession session){
if ((Member) session.getAttribute("sMember") == null) {
return null;
}
Member member = (Member) session.getAttribute("sMember");
MoneyUseResult moneyUseList = mainChartResourceMapper(member);
return moneyUseList;
}
@RequestMapping(value="mainChart_RevenueCardNamePrinter", produces="application/json; charset=utf-8")
public @ResponseBody String mainChart_RevenueCardNamePrinter(HttpSession session){
if ((Member) session.getAttribute("sMember") == null) {
return null;
}
Member member = (Member) session.getAttribute("sMember");
Date date = new Date();
String formatMonth = String.format("%02d", date.getMonth()+1);
int thisYear = date.getYear()+1900;
ArrayList<HashMap<String, String>> cardListTemp = moneyBookService.selectMoneyBook_CardUsage(thisYear, formatMonth, member.getM_email());
String jsonTemp = "[";
for(int i=0 ;i<cardListTemp.size();i++){
jsonTemp += "{\"cardName\":\""+cardListTemp.get(i).get("c_name")+"\"}";
if(i!=cardListTemp.size()-1)
jsonTemp +=",";
}
jsonTemp += "]";
return jsonTemp;
}
private MoneyUseResult mainChartResourceMapper(Member member) {
Date date = new Date();
String[] thisYear_MonthlyUsed = new String[12];
String[] lastYear_MonthlyUsed = new String[12];
// 올해 총액
int thisYear = date.getYear() + 1900;
for (int i = 0; i <= 11; i++) {
String format = String.format("%02d", i+1);
thisYear_MonthlyUsed[i] = moneyBookService.selectUsedListByMonth(thisYear, format, member.getM_email());
}
// 작년 총액
for (int i = 0; i <= 11; i++) {
String format = String.format("%02d", i+1);
lastYear_MonthlyUsed[i] = moneyBookService.selectUsedListByMonth(thisYear-1, format, member.getM_email());
}
//
String formatMonth = String.format("%02d", date.getMonth()+1);
ArrayList<HashMap<String, String>> cardListTemp = moneyBookService.selectMoneyBook_CardUsage(thisYear, formatMonth, member.getM_email());
ArrayList<HashMap<String, String>> cardList = new ArrayList<HashMap<String, String>>();
for(HashMap<String, String> arr : cardListTemp){
Iterator it = arr.keySet().iterator();
HashMap<String, String> tempMap = new HashMap<String, String>();
while(it.hasNext()){
String key = (String) it.next();
tempMap.put(key, String.valueOf(arr.get(key)));
}
cardList.add(tempMap);
}
MoneyUseResult myr = new MoneyUseResult();
myr.setThis_Jan(thisYear_MonthlyUsed[0]==null?"0":thisYear_MonthlyUsed[0]);
myr.setThis_Feb(thisYear_MonthlyUsed[1]==null?"0":thisYear_MonthlyUsed[1]);
myr.setThis_Mar(thisYear_MonthlyUsed[2]==null?"0":thisYear_MonthlyUsed[2]);
myr.setThis_Apr(thisYear_MonthlyUsed[3]==null?"0":thisYear_MonthlyUsed[3]);
myr.setThis_May(thisYear_MonthlyUsed[4]==null?"0":thisYear_MonthlyUsed[4]);
myr.setThis_Jun(thisYear_MonthlyUsed[5]==null?"0":thisYear_MonthlyUsed[5]);
myr.setThis_Jul(thisYear_MonthlyUsed[6]==null?"0":thisYear_MonthlyUsed[6]);
myr.setThis_Aug(thisYear_MonthlyUsed[7]==null?"0":thisYear_MonthlyUsed[7]);
myr.setThis_Sep(thisYear_MonthlyUsed[8]==null?"0":thisYear_MonthlyUsed[8]);
myr.setThis_Oct(thisYear_MonthlyUsed[9]==null?"0":thisYear_MonthlyUsed[9]);
myr.setThis_Nov(thisYear_MonthlyUsed[10]==null?"0":thisYear_MonthlyUsed[10]);
myr.setThis_Dec(thisYear_MonthlyUsed[11]==null?"0":thisYear_MonthlyUsed[11]);
myr.setLast_Jan(lastYear_MonthlyUsed[0]==null?"0":lastYear_MonthlyUsed[0]);
myr.setLast_Feb(lastYear_MonthlyUsed[1]==null?"0":lastYear_MonthlyUsed[1]);
myr.setLast_Mar(lastYear_MonthlyUsed[2]==null?"0":lastYear_MonthlyUsed[2]);
myr.setLast_Apr(lastYear_MonthlyUsed[3]==null?"0":lastYear_MonthlyUsed[3]);
myr.setLast_May(lastYear_MonthlyUsed[4]==null?"0":lastYear_MonthlyUsed[4]);
myr.setLast_Jun(lastYear_MonthlyUsed[5]==null?"0":lastYear_MonthlyUsed[5]);
myr.setLast_Jul(lastYear_MonthlyUsed[6]==null?"0":lastYear_MonthlyUsed[6]);
myr.setLast_Aug(lastYear_MonthlyUsed[7]==null?"0":lastYear_MonthlyUsed[7]);
myr.setLast_Sep(lastYear_MonthlyUsed[8]==null?"0":lastYear_MonthlyUsed[8]);
myr.setLast_Oct(lastYear_MonthlyUsed[9]==null?"0":lastYear_MonthlyUsed[9]);
myr.setLast_Nov(lastYear_MonthlyUsed[10]==null?"0":lastYear_MonthlyUsed[10]);
myr.setLast_Dec(lastYear_MonthlyUsed[11]==null?"0":lastYear_MonthlyUsed[11]);
myr.setCardList(cardList);
return myr;
}
}
| [
"songyj0720@naver.com"
] | songyj0720@naver.com |
b36daa24a069a4d78ad5f6178d6c3334c72716fb | f3db3a93ba1549514c56ca43916d78b0b14d2db6 | /src/main/java/com/yikang/error/BusinessException.java | 549cd5f05cb40ec82bfb4bb83a3f5af2b2ec1a77 | [] | no_license | DengYiKang/miaosha | 92beecbbc9091d4a478e717c938c3aacb3282eb8 | a1b8f55eccd45e24cb82a08115c8387b96cb5e97 | refs/heads/master | 2023-04-06T06:53:31.922998 | 2021-04-15T10:12:33 | 2021-04-15T10:12:33 | 346,383,429 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 950 | java | package com.yikang.error;
//包装器业务异常类实现
public class BusinessException extends RuntimeException implements CommonError {
private CommonError commonError;
//直接接收EmBuinessError的传参用于构造业务异常
public BusinessException(CommonError commonError) {
super();
this.commonError = commonError;
}
//接收自定义ErrMsg的方式构造业务异常
public BusinessException(CommonError commonError, String errMsg) {
super();
this.commonError = commonError;
this.commonError.setErrorMsg(errMsg);
}
@Override
public int getErrorCode() {
return this.commonError.getErrorCode();
}
@Override
public String getErrorMsg() {
return this.commonError.getErrorMsg();
}
@Override
public CommonError setErrorMsg(String errorMsg) {
this.commonError.setErrorMsg(errorMsg);
return this;
}
}
| [
"1131487340@qq.com"
] | 1131487340@qq.com |
0b7990da693630f00c8538f0b6946e0029111f6f | b2eda080b18e12a9491878332430eb3a6ecc454f | /applications/spring-shell/src/test/java/org/springframework/sbm/mule/amqp/RabbitMqListener.java | af026723533c9e5b6b23e58484d776667ad64c8a | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | spring-projects-experimental/spring-boot-migrator | 300a3747ffc84b9654a1ee2abe8a7a5f1acf5a87 | e8fcb8d47d898d86fcf24c25e2ed7f5e56cb0bae | refs/heads/main | 2023-08-16T19:43:50.867155 | 2023-08-06T12:16:20 | 2023-08-06T12:16:20 | 460,537,559 | 341 | 77 | Apache-2.0 | 2023-09-14T11:17:46 | 2022-02-17T17:26:36 | Java | UTF-8 | Java | false | false | 2,169 | java | /*
* Copyright 2021 - 2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.sbm.mule.amqp;
import com.rabbitmq.client.DeliverCallback;
import com.rabbitmq.client.Delivery;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
public class RabbitMqListener implements DeliverCallback {
private final String expectedMessage;
private final Map<String, String> expectedHeaders;
private final CountDownLatch latch = new CountDownLatch(1);
public RabbitMqListener(String expectedMessage, Map<String, String> expectedHeaders) {
this.expectedMessage = expectedMessage;
this.expectedHeaders = expectedHeaders;
}
public CountDownLatch getLatch() {
return latch;
}
@Override
public void handle(String s, Delivery delivery) {
String receivedMessage = new String(delivery.getBody(), StandardCharsets.UTF_8);
Map<String, Object> receivedHeader = delivery.getProperties().getHeaders();
boolean headersMatch = expectedHeaders.entrySet().stream()
.allMatch(
p -> receivedHeader.get(p.getKey()).toString().equals(p.getValue())
);
System.out.println(" [x] Received ampq message: '" + receivedMessage + "'");
System.out.println(" [x] Does amqp header match? : " + headersMatch);
if (receivedMessage.equals(expectedMessage) && headersMatch) {
latch.countDown();
}
}
}
| [
"noreply@github.com"
] | spring-projects-experimental.noreply@github.com |
be643d295663c9d8cc77aaed6f329bca361600b6 | 889f8f8c7f89f6be2362c8fa16a564b29893ac25 | /java/org/kashish/facetoons/Adapter/LoginApapter.java | 13cd49a297e1862e60072bddd2d016451d02fdd9 | [] | no_license | kartikeyahl/white_box_cartoonization_js | 501e6383d3c38f38eb3983c6b8a68e2b92ebc024 | fc1eec85c211ea98a47857014307d406fc12c059 | refs/heads/main | 2023-01-22T00:45:31.318902 | 2020-11-22T05:59:40 | 2020-11-22T05:59:40 | 314,799,437 | 1 | 1 | null | 2020-11-21T11:47:36 | 2020-11-21T11:47:35 | null | UTF-8 | Java | false | false | 1,148 | java | package org.kashish.facetoons.Adapter;
import android.content.Context;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import org.kashish.facetoons.boarding_fragment.LoginTabFragment;
import org.kashish.facetoons.boarding_fragment.SignupTabFragment;
public class LoginApapter extends FragmentPagerAdapter {
private Context context;
int totalTabs;
public LoginApapter(FragmentManager fm, Context context, int totalTabs){
super(fm);
this.context=context;
this.totalTabs=totalTabs;
}
@Override
public int getCount() {
return totalTabs;
}
public Fragment getItem(int position){
switch(position){
case 0:
LoginTabFragment loginTabFragment = new LoginTabFragment();
return loginTabFragment;
case 1:
SignupTabFragment signupTabFragment = new SignupTabFragment();
return signupTabFragment;
default:
return null;
}
}
}
| [
"noreply@github.com"
] | kartikeyahl.noreply@github.com |
773b436b481da314aad31f4c71136561639f4ef0 | 3b9e30c054c637cab6c9160c24f1711d2433dd7c | /C++:Java/Pep8 Compiler/build/classes/prob0720/ACode.java | 812938e4f5185d74ae456855a34175c65b6bd1a9 | [] | no_license | Frank-The-Tank/Portfolio | f0e7e179eacbea69425ad9d0ca429bac80c4c7a0 | 376c8a96cfe60c7c7b3c0a26b18b99f4eee0bcaa | refs/heads/master | 2021-01-11T08:49:36.854088 | 2016-12-22T18:03:19 | 2016-12-22T18:03:19 | 76,802,548 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 355 | 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 prob0720;
/**
*
* @Frank Garcia
*/
abstract public class ACode {
public abstract String generateListing();
public abstract String generateCode();
}
| [
"futboler101@yahoo.com"
] | futboler101@yahoo.com |
bc3cf3a01e87360ab87ebaa7cca34df5a74a72c4 | deb551b7e3147ec369c9c1e0ec2cff0844a86f8d | /src/it/polito/yutengfei/RIIF2/Declarator/ChildComponentDeclarator.java | 71b247f8608a82ec3dd97078488eb29e30ab45ae | [] | no_license | yutengfei246/RIIF2_v6 | 98ea1d46bff6c5698d5174776201bd4b900f250b | 9971051b5eecbc6f862c7e53e1a382cd74155cb6 | refs/heads/master | 2021-01-12T06:16:57.420891 | 2017-01-15T13:21:59 | 2017-01-15T13:21:59 | 77,335,439 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 876 | java | package it.polito.yutengfei.RIIF2.Declarator;
import it.polito.yutengfei.RIIF2.id.DeclaratorId;
import it.polito.yutengfei.RIIF2.initializer.Initializer;
import it.polito.yutengfei.RIIF2.parser.typeUtility.RIIF2Type;
public class ChildComponentDeclarator implements Declarator {
private DeclaratorId declaratorId;
private RIIF2Type CCType;
@Override
public void setDeclaratorId(DeclaratorId declaratorId) {
this.declaratorId = declaratorId;
}
@Override
public void setInitializer(Initializer initializer) {}
@Override
public DeclaratorId getDeclaratorId() {
return declaratorId;
}
@Override
public Initializer getInitializer() {
return null;
}
public void setCCType(RIIF2Type CCType) {
this.CCType = CCType;
}
public RIIF2Type getCCType() {
return CCType;
}
}
| [
"yutengfei229@hotmail.com"
] | yutengfei229@hotmail.com |
a2a85c12d3e3aedf064818a30c78670f05f6dd32 | 6fba4800b3852b95c336e0bf9768eaf928d9da20 | /data-plane/core/src/main/java/dev/knative/eventing/kafka/broker/core/Filter.java | efbe878bd7656a4feff54cd0c1b71fb0e382e235 | [
"Apache-2.0"
] | permissive | markusthoemmes/eventing-kafka-broker | c612eabf3958d5cb7a731d6cafda53daa035002d | 7b905cc3c716c3b5a08916dcaadaeaccf7ba09a9 | refs/heads/master | 2023-03-20T06:47:38.161275 | 2020-09-09T07:48:50 | 2020-09-09T07:48:50 | 294,062,404 | 0 | 0 | null | 2020-09-09T09:14:14 | 2020-09-09T09:14:13 | null | UTF-8 | Java | false | false | 840 | java | /*
* Copyright 2020 The Knative Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.knative.eventing.kafka.broker.core;
/**
* Filter interface abstract the filtering logic.
*
* @param <T> type of objects to filter.
*/
@FunctionalInterface
public interface Filter<T> {
boolean match(final T event);
}
| [
"noreply@github.com"
] | markusthoemmes.noreply@github.com |
42c796821d8b00117ca1773d5d135d76841366ba | 25dc737916376d5b765430acc1554ef848739f21 | /testprovider/src/main/java/com/test/springcloud/provider/entity/User.java | eb4e53ff44911f1058fc764909e11cc00d8028e6 | [] | no_license | youhouhouhou/testspringcloud | 42bc0c5ba296a5cd7567c409f3a0ed17dcf3d7c2 | 7db45bac4956361d5d61fd5358c0126aca896c3f | refs/heads/master | 2021-01-19T06:48:20.413297 | 2017-04-07T06:09:49 | 2017-04-07T06:09:49 | 87,501,986 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 473 | java | package com.test.springcloud.provider.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
* Created by zhuzhujier on 17-2-9.
*/
@Entity
@Data
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column
private String username;
@Column
private Integer age;
}
| [
"shuangjiefeng@creditease.cn"
] | shuangjiefeng@creditease.cn |
cb494c30f7b5f6c93fd26055df055109a49f643d | 5796660092bda17bc8fb350b594b5a54cf61477a | /Raytracer/intersection/Quartic.java | 215dee391c78f53a9fc479a2da522094e03a51f2 | [] | no_license | Remsko/RT-JAVA | ce28b30aa616a0b941f90c69be3403f6e4acd2c5 | d35a92291b041aff49531e481ca219f0841cff16 | refs/heads/master | 2020-03-13T17:00:59.979228 | 2018-10-17T15:47:15 | 2018-10-17T15:47:15 | 131,210,093 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,420 | java | package intersection;
public class Quartic
{
public static final double TWO_PI_43 = 4.1887902047863909846168;
public static final double TWO_PI_3 = 2.0943951023931954923084;
public static final double EPSILON = 1.0e-10;
public double CubicRoots[] = new double[3];
public double QuarticRoots[] = new double[4];
public double smallest = Double.MAX_VALUE;
public boolean isanswer = false;
public int solveCubic(double a, double b, double c, double d)
{
double a0 = a;
double a1 = b / a0;
double a2 = c / a0;
double a3 = d / a0;
double A2 = a1 * a1;
double Q = (A2 - 3.0 * a2) / 9.0;
double R = (a1 * (A2 - 4.5 * a2) + 13.5 * a3) / 27.0;
double Q3 = Q * Q * Q;
double R2 = R * R;
double D = Q3 - R2;
double an = a1 / 3.0;
if (D >= 0.0)
{
D = R / Math.sqrt (Q3);
double theta = Math.acos(d) / 3.0;
double sQ = -2.0 * Math.sqrt(Q);
CubicRoots[0] = sQ * Math.cos (theta) - an;
CubicRoots[1] = sQ * Math.cos (theta + TWO_PI_3) - an;
CubicRoots[2] = sQ * Math.cos (theta + TWO_PI_43) - an;
return (3);
}
else
{
double sQ = Math.pow(Math.sqrt (R2 - Q3) + Math.abs(R), 1.0 / 3.0);
if (R < 0)
CubicRoots[0] = (sQ + Q / sQ) - an;
else
CubicRoots[0] = -(sQ + Q / sQ) - an;
return (1);
}
}
public int solveQuartic(double a, double b, double c, double d, double e)
{
//double c0 = a;
double c1 = b / a;
double c2 = c / a;
double c3 = d / a;
double c4 = e / a;
double c12 = c1 * c1;
double p = -0.375 * c12 + c2;
double q = 0.125 * c12 * c1 - 0.5 * c1 * c2 + c3;
double r = -0.01171875 * c12 * c12 + 0.0625 * c12 * c2 - 0.25 * c1 * c3 + c4;
double A = 1.0;
double B = -0.5 * p;
double C = -r;
double D = 0.5 * r * p - 0.125 * q * q;
int i = solveCubic(A, B, C, D);
double z;
if (i > 0)
z = CubicRoots[0];
else
return (0);
double d1 = 2.0 * z - p;
double d2;
if (d1 < 0.0)
{
if (d1 > -EPSILON)
d1 = 0.0;
else
return 0;
}
if (d1 < EPSILON)
{
d2 = z * z - r;
if (d2 < 0.0)
return (0);
d2 = Math.sqrt(d2);
}
else
{
d1 = Math.sqrt (d1);
d2 = 0.5 * q / d1;
}
double q1 = d1 * d1;
double q2 = -0.25 * c1;
i = 0;
p = q1 - 4.0 * (z - d2);
if (p == 0)
QuarticRoots[i++] = -0.5 * d1 - q2;
else if (p > 0)
{
p = Math.sqrt(p);
QuarticRoots[i++] = -0.5 * (d1 + p) + q2;
QuarticRoots[i++] = -0.5 * (d1 - p) + q2;
}
p = q1 - 4.0 * (z + d2);
if (p == 0)
QuarticRoots[i++] = 0.5 * d1 - q2;
else if (p > 0)
{
p = Math.sqrt(p);
QuarticRoots[i++] = 0.5 * (d1 + p) + q2;
QuarticRoots[i++] = 0.5 * (d1 - p) + q2;
}
return i;
}
public Quartic(double a, double b, double c, double d, double e)
{
int i = solveQuartic(a, b, c, d, e);
int j = 0;
while (j < i)
{
if (QuarticRoots[j] > 0.0 && QuarticRoots[j] < smallest)
{
smallest = QuarticRoots[j];
isanswer = true;
}
j++;
}
}
}
| [
"pinoit.remi@gmail.com"
] | pinoit.remi@gmail.com |
b50ada5aaf4cab5fd9b981ef942abf19b407e05d | aaff631c606ad1dcaf6097eeff0b3cb225fd0dca | /src/main/Server/data/Difficulty.java | abca19005aabbfc2e63e4129b750eb73273d7279 | [] | no_license | tss15/Lab6_2 | 44c7f3e128ae2996c5f9b321be2f48d551e53064 | 0d874730e7612a917c996b26f82d9d094e4ef649 | refs/heads/master | 2023-08-01T14:13:19.969043 | 2021-09-11T11:55:22 | 2021-09-11T11:55:22 | 403,773,074 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 159 | java | package data;
import java.io.Serializable;
public enum Difficulty implements Serializable {
VERY_EASY,
NORMAL,
HARD,
HOPELESS,
TERRIBLE
} | [
"tania_shokor_15@hotmail.com"
] | tania_shokor_15@hotmail.com |
48a43679718aa034967b546506c45e7a8dc4165e | 51610e0749890f43ff02d8eae2943e921b796780 | /DebtLedger/app/src/main/java/cs4474/g9/debtledger/ui/groups/select/OnGroupChecked.java | 5ca62fe06eb310a7e1ef2b1be3a6b550d833ef07 | [] | no_license | ralphbarac/Android-Debt-Ledger | 5cf31c66b05200cc34e69f7b8d34f786cb89d95d | b86d9663b16bd1589f14175239b8096f205a390e | refs/heads/master | 2022-04-11T14:58:17.915174 | 2020-04-06T21:25:55 | 2020-04-06T21:25:55 | 239,007,193 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 212 | java | package cs4474.g9.debtledger.ui.groups.select;
import cs4474.g9.debtledger.data.model.Group;
public interface OnGroupChecked {
void onGroupChecked(Group group);
void onGroupUnchecked(Group group);
}
| [
"zainsirohey@gmail.com"
] | zainsirohey@gmail.com |
d7237bac4d0098beb869dfe5874960d95dd87fec | 820eb921027f2c1cccb4ef028ef5e84b4156ff42 | /src/DecoratorPattern/Espresso.java | c119f6371ad2d67ac6fa45c8dfdd95fd76c8ff27 | [] | no_license | mpsshubham/DesignPatterns | f37f40b8e6772be21de9d2a7f9edaafa8ba108bb | 5a69327538f78003fd1e73105a025df93be90ada | refs/heads/master | 2023-04-15T11:16:58.331137 | 2021-04-13T16:41:13 | 2021-04-13T16:41:13 | 352,875,899 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 189 | java | package DecoratorPattern;
public class Espresso extends Beverage {
public Espresso() {
description = "Espresso";
}
@Override
public double cost() {
return 1.99;
}
}
| [
"mpsshubham@gmail.com"
] | mpsshubham@gmail.com |
84de356b366419c6ac17d5c044e0c666f1716ee2 | c4c3ce36059724a4206fed992176d88681bd8f83 | /src/main/java/com/example/demo/services/IUserServiceImpl.java | 9b38fd52e6bc51686034d3ed0ed2a20b87f34fd2 | [] | no_license | AngelGuante/WebApp_GestionCheques | e36cb5ae090bfeb8f954e1480dce17f736388867 | 6d131868be88e28feab50306d9af13bf0b3514da | refs/heads/master | 2020-05-05T01:14:55.453246 | 2019-04-05T00:34:24 | 2019-04-05T00:34:24 | 179,597,238 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,657 | java | package com.example.demo.services;
import org.springframework.data.domain.Pageable;
import javax.transaction.Transactional;
import com.example.demo.entities.SecurityUser;
import com.example.demo.repository.IUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
@Service
public class IUserServiceImpl implements IUserService {
@Autowired
IUserRepository repo;
@Override
public void createUser(SecurityUser user) {
if (user != null) {
this.repo.save(user);
}
}
@Override
public Iterable<SecurityUser> readAll() {
return this.repo.findAll();
}
@Override
public void updateUser(long id) {
SecurityUser user = null;
if (id > 0) {
user = this.repo.findById(id).orElse(null);
this.repo.save(user);
}
}
@SuppressWarnings("unused")
@Override
public void deleteUser(long id) {
SecurityUser user = null;
if (user != null) {
user = this.repo.findById(id).orElse(null);
this.repo.delete(user);
}
}
@Override
public SecurityUser findById(long id) {
return repo.findById(id).orElse(null);
}
@Override
@Transactional
public Page<SecurityUser> FindAllUsers(Pageable pageable) {
return repo.FindAllUsers(pageable);
}
@Override
@Transactional
public Page<SecurityUser> FindUsersByParameters(String texto, Pageable pageRequest) {
return repo.FindUsersByParameters(texto, pageRequest);
}
}
| [
"miguel_guante@outlook.com"
] | miguel_guante@outlook.com |
c2ba1f2454db6416ee56ced07aad25b6d972490b | b5a03d3aaac3622b19bd50dd323b88ed11128c21 | /BE MY GUIDE version 1/MyApplicationVFinal/MyApplication/app/src/main/java/com/example/myapplication/place.java | 8d905e62f215265602d16af6817d94cbf0201b0c | [] | no_license | oudersamir/ByMyGuide_Android | cae22001088e8a684949fd7c8b0dcab85aff146c | 063da97e6eee521ea0c36d15048d82cd0cc453c2 | refs/heads/master | 2023-01-28T21:17:58.636071 | 2020-12-08T21:38:40 | 2020-12-08T21:38:40 | 319,762,225 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,517 | java | package com.example.myapplication;
public class place {
private long id;
private int number;
private double lng;
private double lat;
private String place;
private int zoom;
private int statut;
private double notes;
public place(){
}
public place(double lng, double lat, String place, int zoom) {
this.lng = lng;
this.lat = lat;
this.place = place;
this.zoom = zoom;
}
public place(double lng, double lat, String place, int zoom,double notes) {
this.lng = lng;
this.lat = lat;
this.place = place;
this.zoom = zoom;
this.notes=notes;
}
public place(double lng, double lat, String place, int zoom,int statut) {
this.lng = lng;
this.lat = lat;
this.place = place;
this.zoom = zoom;
this.statut=statut;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public place(double lng, double lat, String place, int zoom, int statut, double notes) {
this.lng = lng;
this.lat = lat;
this.place = place;
this.zoom = zoom;
this.statut=statut;
this.notes=notes;
}
@Override
public String toString() {
return "place{" +
"id=" + id +
", lng=" + lng +
", lat=" + lat +
", place='" + place + '\'' +
", zoom=" + zoom +
", statut=" + statut +
", notes=" + notes +
'}';
}
public void setNotes(double notes) {
this.notes = notes;
}
public double getNotes() {
return notes;
}
public void setId(long id) {
this.id = id;
}
public void setStatut(int statut) {
this.statut= statut;
}
public int getStatut() {
return statut;
}
public void setLng(double lng) {
this.lng = lng;
}
public void setLat(double lat) {
this.lat = lat;
}
public void setPlace(String place) {
this.place = place;
}
public void setZoom(int zoom) {
this.zoom = zoom;
}
public long getId() {
return id;
}
public double getLng() {
return lng;
}
public double getLat() {
return lat;
}
public String getPlace() {
return place;
}
public int getZoom() {
return zoom;
}
}
| [
"ouder.samir@gmail.com"
] | ouder.samir@gmail.com |
ee8f27067e67304772a15c78e697250a6ab4a19b | 168eb30cb5b6427e00080339efa9a904eca0aae2 | /src/main/java/org/uichuimi/coat/view/vcfcombiner/StatusComboBoxCell.java | 4615ca6607919b68d9ef8dbd5a4eb036c0a465bc | [] | no_license | uichuimi/Coat | 5f7b85ae3b64227fa059e5526ec936144ba61681 | ab35adc31bc2079a2de916289e48c1491cfcf802 | refs/heads/master | 2022-12-10T15:14:46.882345 | 2021-02-12T10:12:02 | 2021-02-12T10:12:02 | 30,242,038 | 0 | 0 | null | 2022-12-02T22:21:50 | 2015-02-03T12:41:27 | Java | UTF-8 | Java | false | false | 2,612 | java | /*
* Copyright (c) UICHUIMI 2017
*
* This file is part of Coat.
*
* Coat is free software:
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* Coat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with Coat.
*
* If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.uichuimi.coat.view.vcfcombiner;
import javafx.collections.FXCollections;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TableCell;
/**
* Cell for the VcfSampleTableView which shows the level of affection of the sample.
*
* @author Lorente Arencibia, Pascual (pasculorente@gmail.com)
*/
class StatusComboBoxCell extends TableCell<Sample, Genotype> {
private final ComboBox<Genotype> comboBox = new ComboBox<>(FXCollections
.observableArrayList(Genotype.values()));
public StatusComboBoxCell() {
// comboBox.setCellFactory(param -> new StatusCell());
// comboBox.setButtonCell(new StatusCell());
comboBox.setOnAction(event -> commitEdit(comboBox.getValue()));
}
@Override
protected void updateItem(Genotype item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
setText(item.toString());
setGraphic(null);
// setGraphic(new SizableImageView("coat/img/black/" + item.name().toLowerCase() + ".png", SizableImageView.SMALL_SIZE));
}
}
@Override
public void startEdit() {
super.startEdit();
comboBox.setValue(getItem());
setGraphic(comboBox);
setText(null);
}
@Override
public void cancelEdit() {
super.cancelEdit();
setText(getItem().toString());
setGraphic(null);
// setGraphic(new SizableImageView("coat/img/black/" + getItem().name().toLowerCase() + ".png", SizableImageView
// .SMALL_SIZE));
}
@Override
public void commitEdit(Genotype newValue) {
super.commitEdit(newValue);
final Sample sample = getTableRow().getItem();
sample.setGenotype(newValue);
setText(newValue.toString());
setGraphic(null);
}
}
| [
"pasculorente@gmail.com"
] | pasculorente@gmail.com |
138d90f5ee362e18fbacfb3aafe8eac9ef03dde3 | dc2c0a1e63d22474cd8d5370103ec1ed73f5dcfb | /head-first-design-pattern/src/com/test/hfdp/command/Command.java | ce79f173055a1858b5ebc2c8d16a8b7f21fe14e6 | [] | no_license | jitu1991/CoreJava | f1af0b4f3af8f0176c0324ba202843a0d362b5a2 | 8bc74b50e53b2b12bdea3af23a1523c7e563c952 | refs/heads/master | 2022-07-08T19:45:32.500177 | 2021-05-04T11:37:02 | 2021-05-04T11:56:00 | 137,873,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 105 | java | package com.test.hfdp.command;
public interface Command {
public void execute();
public void undo();
} | [
"jitender.kumar@irissoftware.com"
] | jitender.kumar@irissoftware.com |
1bae84c460c7567e2d0cb27856d06d0f2967d9b8 | 8ab1fe4fd0aac261a80b58ec6d5be0abf5a91dee | /src/main/java/com/ssafy/happyhouse/service/StoreServiceImpl.java | c7d1bb1a209cfa4a84566115d0d965807a6a4ff0 | [] | no_license | wonthechan/chan-happyhouse-spring | 96ba12bc3dd8c8b7856c0e3bf9cbbd482fb0d5b5 | 5dc09c25b40c341574c7a4bc7e1e69ef2aff18ec | refs/heads/master | 2022-11-06T03:55:15.668729 | 2020-06-20T05:32:09 | 2020-06-20T05:32:09 | 273,645,956 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 756 | java | package com.ssafy.happyhouse.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ssafy.happyhouse.dto.StoreInfo;
import com.ssafy.happyhouse.mapper.StoreMapper;
@Service
public class StoreServiceImpl implements StoreService{
@Autowired
StoreMapper storeMapper;
@Override
public List<StoreInfo> findStoresByDong(String dongcode, int offset, int limit) {
return storeMapper.selectStoresByDong(dongcode, offset, limit);
}
@Override
public int searchStoresTotalCnt(String dongcode) {
return storeMapper.selectStoresTotalCnt(dongcode);
}
@Override
public StoreInfo getEveryDetail(int no) {
return storeMapper.selectEveryDetail(no);
}
}
| [
"packerstorm@gmail.com"
] | packerstorm@gmail.com |
49977e1a8290be57f616c7a294a5b3dc5923eb49 | 154f56045ec082e0c7a749754cf1133250cc4d2f | /EmployeeManager/src/main/java/com/manager/config/JwtRequestFilter.java | f68d51e8a031a91b686aa47088e25cb0bf64ebca | [] | no_license | qngson/qngson.github.io | 8ee6f54358e38683f8a506d55dea9ac0ac1928bd | 35372cdca07466fd1f65eceb54c487a5992429a3 | refs/heads/master | 2022-12-22T07:53:50.695806 | 2021-01-25T01:10:18 | 2021-01-25T01:10:18 | 226,000,461 | 0 | 0 | null | 2022-12-10T00:38:03 | 2019-12-05T02:38:30 | Java | UTF-8 | Java | false | false | 3,217 | java | package com.manager.config;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import com.manager.jwtservice.JwtUserDetailsService;
import io.jsonwebtoken.ExpiredJwtException;
@Component
public class JwtRequestFilter extends OncePerRequestFilter {
@Autowired
private JwtUserDetailsService jwtUserDetailsService;
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
final String requestTokenHeader = request.getHeader("Authorization");
String username = null;
String jwtToken = null;
// JWT Token is in the form "Bearer token". Remove Bearer word and get
// only the Token
if (requestTokenHeader != null && requestTokenHeader.startsWith("Bearer ")) {
jwtToken = requestTokenHeader.substring(7);
try {
username = jwtTokenUtil.getUsernameFromToken(jwtToken);
} catch (IllegalArgumentException e) {
System.out.println("Unable to get JWT Token");
} catch (ExpiredJwtException e) {
System.out.println("JWT Token has expired");
}
} else {
logger.warn("JWT Token does not begin with Bearer String");
}
// Once we get the token validate it.
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
UserDetails userDetails = this.jwtUserDetailsService.loadUserByUsername(username);
// if token is valid configure Spring Security to manually set
// authentication
if (jwtTokenUtil.validateToken(jwtToken, userDetails)) {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(
userDetails, null, userDetails.getAuthorities());
usernamePasswordAuthenticationToken
.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
// After setting the Authentication in the context, we specify
// that the current user is authenticated. So it passes the
// Spring Security Configurations successfully.
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
}
}
chain.doFilter(request, response);
}
}
| [
"Admin@Admin.mshome.net"
] | Admin@Admin.mshome.net |
2f8ccf48a78c9276321dbb82c42fde91a74bae96 | bf9ebeab417539930d6760317d3373b6b5f664d2 | /app/src/main/java/com/field/datamatics/json/ProductJson.java | b25623af35424904de0d3f92e2417895f3bd6b9a | [] | no_license | ItsMeAnoop/FDM | e144715beb4e94e5433f71a2a83372a0055451ca | a51cacdd51c07161e95d209273e91f55097a556b | refs/heads/master | 2021-12-13T23:56:01.984379 | 2021-12-05T05:08:07 | 2021-12-05T05:08:07 | 62,947,917 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,249 | java | package com.field.datamatics.json;
import com.field.datamatics.database.AppDatabase;
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.data.Blob;
import com.raizlabs.android.dbflow.structure.BaseModel;
/**
* Created by Jith on 10/7/2015.
*/
public class ProductJson {
public String Product_Number;
public String Product_Description;
public String Barcode;
public String Category;
public String Category_desc;
public String Subcategory;
public String Subcat_desc;
public String UOM;
public String Pack_Size;
public Blob Photo;
public String Narration;
public String Supplier_Name;
public String Supplier_desc;
public int Stock_Availability;
public String Usage;
public int On_PO;
public String Department;
public String Department_desc;
public String section;
public String Section_desc;
public String Family;
public String Family_desc;
public String Subfamily;
public String Subfamily_desc;
public boolean Status;
public String Remarks;
}
| [
"anoop.r@experionlobal.com"
] | anoop.r@experionlobal.com |
421f8b91eb5b44f388ab6a78fe0b456ea7c6ee6f | bbc33908851cd30dcf816a9e549f6e7bcc9fedc9 | /html/src/com/mygdx/mygame/client/HtmlLauncher.java | 8f7187322338caa94a613caa02064dc768ddb0e8 | [] | no_license | hoangphat1908/MyGame | 2520ec4599247cd18a7aa6bebdf69012f6181f52 | 4583e30d442f367bd2a9fcdb719f2fe0b1ac1d73 | refs/heads/master | 2021-01-19T17:09:52.763308 | 2017-05-16T02:34:23 | 2017-05-16T02:34:23 | 88,310,410 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 568 | java | package com.mygdx.mygame.client;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.mygdx.mygame.MyGame;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(480, 320);
}
@Override
public ApplicationListener createApplicationListener () {
return new MyGame();
}
} | [
"hoangphat1908@gmail.com"
] | hoangphat1908@gmail.com |
bcaa3b0eda41869c7fb43171c707228fe0be9baa | 1fad4cb6f73a3787636d0c7526352bb441df22cd | /src/main/com/jumkid/live/google/geocoding/GeocodingResponse.java | 8ff9fc2bbd649dda43d7329fd5410065158eb4b9 | [] | no_license | chooli/com.jumkid.live | 7d92969535fb7d1b0c8e68c2fc8e11f97e570e62 | 22214073865498bc68de3b75b7463654a259c97a | refs/heads/master | 2020-03-30T07:08:54.328217 | 2015-07-08T15:31:45 | 2015-07-08T15:31:45 | 38,758,529 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 979 | java | package com.jumkid.live.google.geocoding;
import com.jumkid.live.google.Status;
/*
* This software is written by Jumkid Ltd. and subject
* to a contract between Jumkid and its customer.
*
* This software stays property of Jumkid unless differing
* arrangements between Jumkid and its customer apply.
*
*
* http://www.jumkid.com
* mailto:info@jumkid.com
*
* (c)2014 Jumkid Innovation. All rights reserved.
*
* VERSION | DATE | DEVELOPER | DESC
* -----------------------------------------------------------------
* 0.6 May2015 chooli creation
*
*/
public class GeocodingResponse {
protected Result[] results;
protected Status status;
public GeocodingResponse() {
}
public Result[] getResults() {
return results;
}
public void setResults(Result[] results) {
this.results = results;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
}
| [
"chooli.yip@gmail.com"
] | chooli.yip@gmail.com |
5da78a114fae509ea45e7fd86cd73b5dcf4fd623 | 5bc246278768ae1431af8bd025b0fb76f3176b1f | /ProjectLuan_nga/src/com/example/projectluan/Event.java | 38b9216c0ef51955c1b452ec0e663915c910b3be | [] | no_license | developer1005/Project | de6275e14ee33f42c1cab49d01ff62268af14a9b | 78f6e26dc7aac8602dcb53246125d3762e55460a | refs/heads/master | 2021-01-17T18:55:16.356019 | 2014-10-04T21:09:54 | 2014-10-04T21:09:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,505 | java | package com.example.projectluan;
import android.R.integer;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class Event extends Activity {
ActionBar mActionBar;
TextView mIDTxt;
TextView mNameEventTxt;
TextView mLocationTxt;
TextView mDateTxt;
TextView mHourTxt;
TextView mNoteTxt;
TextView mRemindersTxt;
ListView mListView;
DatabaseController mDbController;
Cursor cursor;
String ID;
int ID1;
String NameEvent;
String Location;
String Date;
String Date1;
String Hour;
String Note;
String Loop;
String Reminders;
String Ringtone;
String SilenceAfter;
String RingtonePath;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.event);
mActionBar = getActionBar();
mActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ca4d3b")));
Intent intent = getIntent();
ID1 = intent.getIntExtra("did", 0);
ID = intent.getStringExtra("id");
mDbController = new DatabaseController(this);
}
@Override
protected void onResume() {
String stSQL = "SELECT * FROM " + DatabaseController.TABLE_NAME + " WHERE " + DatabaseController.ID_COL + "=" + ID + " or " + DatabaseController.ID_COL + "=" + ID1 + ";";
cursor = mDbController.rawQuery(stSQL, null);
if(cursor.moveToFirst()){
do{
mNameEventTxt = (TextView) findViewById(R.id.txtNameEvent);
NameEvent = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.NAME_EVENT_COL));
mNameEventTxt.setText(NameEvent);
mLocationTxt = (TextView)findViewById(R.id.txtLocation);
Location = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.LOCATION_COL));
mLocationTxt.setText(Location);
mDateTxt = (TextView)findViewById(R.id.txtDate);
Date = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.DATE_COL));
Date1 = trimspace(Date);
mDateTxt.setText(Date1);
mHourTxt = (TextView)findViewById(R.id.txtHour);
Hour = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.HOUR_COL));
mHourTxt.setText(Hour);
mNoteTxt = (TextView)findViewById(R.id.txtNote);
Note = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.NOTE_COL));
mNoteTxt.setText(Note);
mRemindersTxt = (TextView)findViewById(R.id.txtR);
Reminders = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.REMINDERS_COL));
mRemindersTxt.setText(Reminders);
Ringtone = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.RINGTONE_COL));
SilenceAfter = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.SILENCE_AFTER_COL));
RingtonePath = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.RINGTONE_PATH_COL));
Loop = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseController.LOOP_COL));
}while (cursor.moveToNext());
}
super.onResume();
}
public String trimspace(String str)
{
str = str.replaceAll("\\s+", " ");
str = str.replaceAll("(^\\s+|\\s+$)", "");
return str;
}
private void deleteEvent() {
String[] id = new String[]{ID};
mDbController.deleteByID(id);
finish();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_event, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.delete:
AlertDialog.Builder builder = new AlertDialog.Builder(Event.this);
builder.setTitle("Xác nhận xóa")
.setMessage("Bạn có muốn xóa sự kiện: " + " \" " + NameEvent + " \" ")
.setCancelable(false)
.setPositiveButton("Xóa", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteEvent();
Toast.makeText(getApplicationContext(), "Bạn đã xóa sự kiện : " + NameEvent, Toast.LENGTH_LONG).show();
}
})
.setNegativeButton("Hủy", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
break;
case R.id.edit:
Intent intent = new Intent();
intent.setClass(getApplicationContext(), EditEvent.class);
intent.putExtra("id", ID);
intent.putExtra("nameEvent", NameEvent);
intent.putExtra("location", Location);
intent.putExtra("date", Date);
intent.putExtra("hour", Hour);
intent.putExtra("note", Note);
intent.putExtra("loop", Loop);
intent.putExtra("reminders", Reminders);
intent.putExtra("ringtone", Ringtone);
intent.putExtra("silenceAfter", SilenceAfter);
intent.putExtra("ringtonePath", RingtonePath);
startActivity(intent);
break;
default:
break;
}
return false;
}
}
| [
"luandt1005@gmail.com"
] | luandt1005@gmail.com |
5aaef8f32f1b3d91c84a7fc4a4ef256c7bcda437 | bc703c071ea79671e4b963b94890ced311d34c76 | /app/src/main/java/com/michen/olaxueyuan/ui/course/video/QuestionVideoPlayManager.java | 12c991d8cd9aaaf3a8de80efcbb71fe69ba59a11 | [] | no_license | uu993/OlaAcademy | 7d4fddc01ebf8bd86b869bd7ee7760ff15099006 | c9ce3d8b057441cc2b9f79b247094276470777e9 | refs/heads/master | 2020-04-03T22:05:52.096362 | 2017-12-05T02:21:46 | 2017-12-05T02:21:46 | 57,137,450 | 1 | 4 | null | 2016-11-17T14:28:54 | 2016-04-26T14:59:22 | Java | UTF-8 | Java | false | false | 7,433 | java | package com.michen.olaxueyuan.ui.course.video;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Rect;
import android.media.AudioManager;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.michen.olaxueyuan.R;
import com.michen.olaxueyuan.common.manager.Utils;
import com.michen.olaxueyuan.ui.me.activity.VideoPlayActivity;
/**
* Created by mingge on 16/3/16.
*/
public class QuestionVideoPlayManager {
private static final int GESTURE_MODIFY_PROGRESS = 1;
private static final int GESTURE_MODIFY_VOLUME = 2;
private static final float STEP_PROGRESS = 0.1f;// 设定进度滑动时的步长,避免每次滑动都改变,导致改变过快
private long palyerCurrentPosition; // 度播放的当前标志,毫秒
private long playerDuration;// 播放资源的时长,毫秒
private Context context;
private int[] location = new int[2];
private int windowWidth;
private int windowHeight;
private static QuestionVideoPlayManager videoManager;
public static QuestionVideoPlayManager getInstance() {
if (videoManager == null) {
videoManager = new QuestionVideoPlayManager();
}
return videoManager;
}
VideoPlayActivity activity;
public void initView(VideoPlayActivity activity) {
this.activity = activity;
}
public boolean setOnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
float mOldX = e1.getX(), mOldY = e1.getY();
int y = (int) e2.getRawY();
int x = (int) e1.getRawX();
windowWidth = Utils.getScreenMetrics(activity).x;
windowHeight = Utils.getScreenMetrics(activity).y;
palyerCurrentPosition = activity.mVideoView.getCurrentPosition();
playerDuration = activity.mVideoView.getDuration();
if (activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
activity.mVideoView.getLocationOnScreen(location);
Rect anchorRect = new Rect(location[0], location[1], location[0] + activity.mVideoView.getWidth(), location[1] + activity.mVideoView.getHeight());
if (mOldY > anchorRect.bottom) {
return false;
}
}
// 横向的距离变化大则调整进度,纵向的变化大则调整音量和亮度
if (Math.abs(distanceX) >= Math.abs(distanceY)) {
activity.mVolumeBrightnessLayout.setVisibility(View.GONE);
activity.gesture_progress_layout.setVisibility(View.VISIBLE);
activity.mVideoView.mMediaController.show();
activity.GESTURE_FLAG = GESTURE_MODIFY_PROGRESS;
if (activity.GESTURE_FLAG == GESTURE_MODIFY_PROGRESS) {
if (Math.abs(distanceX) > Math.abs(distanceY)) {// 横向移动大于纵向移动
if (distanceX >= Utils.dip2px(activity, STEP_PROGRESS)) {// 快退,用步长控制改变速度,可微调
activity.gesture_iv_progress.setImageResource(R.drawable.souhu_player_backward);
if (palyerCurrentPosition > 2 * 1000) {// 避免为负
palyerCurrentPosition -= 2 * 1000;// scroll方法执行一次快退3秒
} else {
palyerCurrentPosition = 2 * 1000;
palyerCurrentPosition = Math.abs((long) (mOldX - x) * 1000);
}
} else if (distanceX <= -Utils.dip2px(activity, STEP_PROGRESS)) {// 快进
activity.gesture_iv_progress.setImageResource(R.drawable.souhu_player_forward);
if (palyerCurrentPosition < playerDuration - 2 * 1000) {// 避免超过总时长
palyerCurrentPosition += 2 * 1000;// scroll执行一次快进3秒
} else {
palyerCurrentPosition = playerDuration - Math.abs((long) (mOldX - x) * 1000);
}
}
activity.geture_tv_progress_time.setText(Utils.converLongTimeToStr(palyerCurrentPosition)
+ "/" + Utils.converLongTimeToStr(playerDuration));
activity.mVideoView.seekTo(palyerCurrentPosition);
}
}
} else {
activity.mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
activity.gesture_progress_layout.setVisibility(View.GONE);
activity.mVideoView.mMediaController.hide();
activity.GESTURE_FLAG = GESTURE_MODIFY_VOLUME;
if (mOldX > windowWidth * 1.0 / 2)// 右边滑动
onVolumeSlide((mOldY - y) / activity.mVideoView.getHeight());
else if (mOldX < windowWidth / 2.0)// 左边滑动
onBrightnessSlide((mOldY - y) / activity.mVideoView.getHeight());
}
return false;
}
/**
* 滑动改变声音大小
*
* @param percent
*/
private void onVolumeSlide(float percent) {
if (activity.mVolume == -1) {
activity.mVolume = activity.mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
if (activity.mVolume < 0)
activity.mVolume = 0;
// 显示
activity.mOperationBg.setImageResource(R.drawable.video_volumn_bg);
activity.mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
}
int index = (int) (percent * activity.mMaxVolume) + activity.mVolume;
if (index > activity.mMaxVolume)
index = activity.mMaxVolume;
else if (index < 0)
index = 0;
// 变更声音
activity.mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
// 变更进度条
ViewGroup.LayoutParams lp = activity.mOperationPercent.getLayoutParams();
lp.width = activity.findViewById(R.id.operation_full).getLayoutParams().width
* index / activity.mMaxVolume;
activity.mOperationPercent.setLayoutParams(lp);
}
/**
* 滑动改变亮度
*
* @param percent
*/
private void onBrightnessSlide(float percent) {
if (activity.mBrightness < 0) {
activity.mBrightness = activity.getWindow().getAttributes().screenBrightness;
if (activity.mBrightness <= 0.00f)
activity.mBrightness = 0.50f;
if (activity.mBrightness < 0.01f)
activity.mBrightness = 0.01f;
// 显示
activity.mOperationBg.setImageResource(R.drawable.video_brightness_bg);
activity.mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
}
WindowManager.LayoutParams lpa = activity.getWindow().getAttributes();
lpa.screenBrightness = activity.mBrightness + percent;
if (lpa.screenBrightness > 1.0f)
lpa.screenBrightness = 1.0f;
else if (lpa.screenBrightness < 0.01f)
lpa.screenBrightness = 0.01f;
activity.getWindow().setAttributes(lpa);
ViewGroup.LayoutParams lp = activity.mOperationPercent.getLayoutParams();
lp.width = (int) (activity.findViewById(R.id.operation_full).getLayoutParams().width * lpa.screenBrightness);
activity.mOperationPercent.setLayoutParams(lp);
}
}
| [
"uu993@163.com"
] | uu993@163.com |
2a56088d1231f044c075882b22c07d7b84607b8d | d523206fce46708a6fe7b2fa90e81377ab7b6024 | /com/parse/ParseObject.java | 8db6a78d30861224b81862a2adc7e4d445632a0a | [] | no_license | BlitzModder/BlitzJava | 0ee94cc069dc4b7371d1399ff5575471bdc88aac | 6c6d71d2847dfd5f9f4f7c716cd820aeb7e45f2c | refs/heads/master | 2021-06-11T15:04:05.571324 | 2017-02-04T16:04:55 | 2017-02-04T16:04:55 | 77,459,517 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 107,946 | java | package com.parse;
import bolts.Capture;
import bolts.Continuation;
import bolts.Task;
import bolts.Task.TaskCompletionSource;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class ParseObject
{
private static final String AUTO_CLASS_NAME = "_Automatic";
public static final String DEFAULT_PIN = "_default";
private static final String KEY_ACL = "ACL";
private static final String KEY_CLASS_NAME = "className";
private static final String KEY_COMPLETE = "__complete";
private static final String KEY_CREATED_AT = "createdAt";
static final String KEY_IS_DELETING_EVENTUALLY = "__isDeletingEventually";
private static final String KEY_IS_DELETING_EVENTUALLY_OLD = "isDeletingEventually";
private static final String KEY_OBJECT_ID = "objectId";
private static final String KEY_OPERATIONS = "__operations";
private static final String KEY_UPDATED_AT = "updatedAt";
private static final String NEW_OFFLINE_OBJECT_ID_PLACEHOLDER = "*** Offline Object ***";
static final String VERSION_NAME = "1.10.2";
private static final Map<Class<? extends ParseObject>, String> classNames;
private static final ThreadLocal<String> isCreatingPointerForObjectId = new ThreadLocal()
{
protected String initialValue()
{
return null;
}
};
private static final Map<String, Class<? extends ParseObject>> objectTypes;
static String server = "https://api.parse.com";
private final Map<String, Object> estimatedData;
private final Map<Object, ParseJSONCacheItem> hashedObjects;
boolean isDeleted;
int isDeletingEventually;
private String localId;
final Object mutex = new Object();
final LinkedList<ParseOperationSet> operationSetQueue;
private final ParseMulticastDelegate<ParseObject> saveEvent = new ParseMulticastDelegate();
private State state;
final TaskQueue taskQueue = new TaskQueue();
static
{
classNames = new ConcurrentHashMap();
objectTypes = new ConcurrentHashMap();
}
protected ParseObject()
{
this("_Automatic");
}
public ParseObject(String paramString)
{
String str2 = (String)isCreatingPointerForObjectId.get();
if (paramString == null) {
throw new IllegalArgumentException("You must specify a Parse class name when creating a new ParseObject.");
}
String str1 = paramString;
if ("_Automatic".equals(paramString)) {
str1 = getClassName(getClass());
}
if ((getClass().equals(ParseObject.class)) && (objectTypes.containsKey(str1)) && (!((Class)objectTypes.get(str1)).isInstance(this))) {
throw new IllegalArgumentException("You must create this type of ParseObject using ParseObject.create() or the proper subclass.");
}
if ((!getClass().equals(ParseObject.class)) && (!getClass().equals(objectTypes.get(str1)))) {
throw new IllegalArgumentException("You must register this ParseObject subclass before instantiating it.");
}
this.operationSetQueue = new LinkedList();
this.operationSetQueue.add(new ParseOperationSet());
this.estimatedData = new HashMap();
this.hashedObjects = new IdentityHashMap();
paramString = newStateBuilder(str1);
if (str2 == null)
{
setDefaultValues();
paramString.isComplete(true);
}
for (;;)
{
this.state = paramString.build();
paramString = Parse.getLocalDatastore();
if (paramString != null) {
paramString.registerNewObject(this);
}
return;
if (!str2.equals("*** Offline Object ***")) {
paramString.objectId(str2);
}
paramString.isComplete(false);
}
}
private void addToHashedObjects(Object paramObject)
{
synchronized (this.mutex)
{
try
{
this.hashedObjects.put(paramObject, new ParseJSONCacheItem(paramObject));
return;
}
catch (JSONException paramObject)
{
throw new IllegalArgumentException("Couldn't serialize container value to JSON.");
}
}
}
private void applyOperations(ParseOperationSet paramParseOperationSet, Map<String, Object> paramMap)
{
Iterator localIterator = paramParseOperationSet.keySet().iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
Object localObject = ((ParseFieldOperation)paramParseOperationSet.get(str)).apply(paramMap.get(str), str);
if (localObject != null) {
paramMap.put(str, localObject);
} else {
paramMap.remove(str);
}
}
}
private boolean canBeSerialized()
{
synchronized (this.mutex)
{
final Capture localCapture = new Capture(Boolean.valueOf(true));
new ParseTraverser()
{
protected boolean visit(Object paramAnonymousObject)
{
if (((paramAnonymousObject instanceof ParseFile)) && (((ParseFile)paramAnonymousObject).isDirty())) {
localCapture.set(Boolean.valueOf(false));
}
if (((paramAnonymousObject instanceof ParseObject)) && (((ParseObject)paramAnonymousObject).getObjectId() == null)) {
localCapture.set(Boolean.valueOf(false));
}
return ((Boolean)localCapture.get()).booleanValue();
}
}.setYieldRoot(false).setTraverseParseObjects(true).traverse(this);
boolean bool = ((Boolean)localCapture.get()).booleanValue();
return bool;
}
}
private void checkForChangesToMutableContainer(String paramString, Object paramObject)
{
ParseJSONCacheItem localParseJSONCacheItem1;
synchronized (this.mutex)
{
if (isContainerObject(paramString, paramObject))
{
localParseJSONCacheItem1 = (ParseJSONCacheItem)this.hashedObjects.get(paramObject);
if (localParseJSONCacheItem1 == null) {
throw new IllegalArgumentException("ParseObject contains container item that isn't cached.");
}
}
}
for (;;)
{
try
{
ParseJSONCacheItem localParseJSONCacheItem2 = new ParseJSONCacheItem(paramObject);
if (!localParseJSONCacheItem1.equals(localParseJSONCacheItem2)) {
performOperation(paramString, new ParseSetOperation(paramObject));
}
return;
}
catch (JSONException paramString)
{
throw new RuntimeException(paramString);
}
this.hashedObjects.remove(paramObject);
}
}
private void checkGetAccess(String paramString)
{
if (!isDataAvailable(paramString)) {
throw new IllegalStateException("ParseObject has no data for '" + paramString + "'. Call fetchIfNeeded() to get the data.");
}
}
private void checkKeyIsMutable(String paramString)
{
if (!isKeyMutable(paramString)) {
throw new IllegalArgumentException("Cannot modify `" + paramString + "` property of an " + getClassName() + " object.");
}
}
private void checkpointAllMutableContainers()
{
synchronized (this.mutex)
{
Iterator localIterator = this.estimatedData.entrySet().iterator();
if (localIterator.hasNext())
{
Map.Entry localEntry = (Map.Entry)localIterator.next();
checkpointMutableContainer((String)localEntry.getKey(), localEntry.getValue());
}
}
}
private void checkpointMutableContainer(String paramString, Object paramObject)
{
synchronized (this.mutex)
{
if (isContainerObject(paramString, paramObject)) {
addToHashedObjects(paramObject);
}
return;
}
}
private static void collectDirtyChildren(Object paramObject, Collection<ParseObject> paramCollection, Collection<ParseFile> paramCollection1)
{
collectDirtyChildren(paramObject, paramCollection, paramCollection1, new HashSet(), new HashSet());
}
private static void collectDirtyChildren(Object paramObject, final Collection<ParseObject> paramCollection, Collection<ParseFile> paramCollection1, final Set<ParseObject> paramSet1, final Set<ParseObject> paramSet2)
{
new ParseTraverser()
{
protected boolean visit(Object paramAnonymousObject)
{
if ((paramAnonymousObject instanceof ParseFile)) {
if (this.val$dirtyFiles != null) {}
}
label188:
for (;;)
{
return true;
paramAnonymousObject = (ParseFile)paramAnonymousObject;
if (((ParseFile)paramAnonymousObject).getUrl() == null)
{
this.val$dirtyFiles.add(paramAnonymousObject);
return true;
if (((paramAnonymousObject instanceof ParseObject)) && (paramCollection != null))
{
ParseObject localParseObject = (ParseObject)paramAnonymousObject;
Object localObject = paramSet1;
paramAnonymousObject = paramSet2;
if (localParseObject.getObjectId() != null) {
paramAnonymousObject = new HashSet();
}
for (;;)
{
if (((Set)localObject).contains(localParseObject)) {
break label188;
}
localObject = new HashSet((Collection)localObject);
((Set)localObject).add(localParseObject);
ParseObject.collectDirtyChildren(localParseObject.estimatedData, paramCollection, this.val$dirtyFiles, (Set)localObject, (Set)paramAnonymousObject);
if (!localParseObject.isDirty(false)) {
break;
}
paramCollection.add(localParseObject);
return true;
if (((Set)paramAnonymousObject).contains(localParseObject)) {
throw new RuntimeException("Found a circular dependency while saving.");
}
paramAnonymousObject = new HashSet((Collection)paramAnonymousObject);
((Set)paramAnonymousObject).add(localParseObject);
}
}
}
}
}
}.setYieldRoot(true).traverse(paramObject);
}
private Map<String, ParseObject> collectFetchedObjects()
{
final HashMap localHashMap = new HashMap();
new ParseTraverser()
{
protected boolean visit(Object paramAnonymousObject)
{
if ((paramAnonymousObject instanceof ParseObject))
{
paramAnonymousObject = (ParseObject)paramAnonymousObject;
ParseObject.State localState = ((ParseObject)paramAnonymousObject).getState();
if ((localState.objectId() != null) && (localState.isComplete())) {
localHashMap.put(localState.objectId(), paramAnonymousObject);
}
}
return true;
}
}.traverse(this.estimatedData);
return localHashMap;
}
public static <T extends ParseObject> T create(Class<T> paramClass)
{
return create(getClassName(paramClass));
}
public static ParseObject create(String paramString)
{
if (objectTypes.containsKey(paramString)) {
try
{
paramString = (ParseObject)((Class)objectTypes.get(paramString)).newInstance();
return paramString;
}
catch (Exception paramString)
{
if ((paramString instanceof RuntimeException)) {
throw ((RuntimeException)paramString);
}
throw new RuntimeException("Failed to create instance of subclass.", paramString);
}
}
return new ParseObject(paramString);
}
public static <T extends ParseObject> T createWithoutData(Class<T> paramClass, String paramString)
{
return createWithoutData(getClassName(paramClass), paramString);
}
/* Error */
public static ParseObject createWithoutData(String paramString1, String paramString2)
{
// Byte code:
// 0: invokestatic 330 com/parse/Parse:getLocalDatastore ()Lcom/parse/OfflineStore;
// 3: astore 4
// 5: aload_1
// 6: ifnonnull +78 -> 84
// 9: getstatic 226 com/parse/ParseObject:isCreatingPointerForObjectId Ljava/lang/ThreadLocal;
// 12: ldc -80
// 14: invokevirtual 588 java/lang/ThreadLocal:set (Ljava/lang/Object;)V
// 17: aconst_null
// 18: astore_3
// 19: aload_3
// 20: astore_2
// 21: aload 4
// 23: ifnull +17 -> 40
// 26: aload_3
// 27: astore_2
// 28: aload_1
// 29: ifnull +11 -> 40
// 32: aload 4
// 34: aload_0
// 35: aload_1
// 36: invokevirtual 591 com/parse/OfflineStore:getObject (Ljava/lang/String;Ljava/lang/String;)Lcom/parse/ParseObject;
// 39: astore_2
// 40: aload_2
// 41: astore_1
// 42: aload_2
// 43: ifnonnull +64 -> 107
// 46: aload_0
// 47: invokestatic 568 com/parse/ParseObject:create (Ljava/lang/String;)Lcom/parse/ParseObject;
// 50: astore_0
// 51: aload_0
// 52: astore_1
// 53: aload_0
// 54: invokevirtual 594 com/parse/ParseObject:hasChanges ()Z
// 57: ifeq +50 -> 107
// 60: new 504 java/lang/IllegalStateException
// 63: dup
// 64: ldc_w 596
// 67: invokespecial 520 java/lang/IllegalStateException:<init> (Ljava/lang/String;)V
// 70: athrow
// 71: astore_0
// 72: aload_0
// 73: athrow
// 74: astore_0
// 75: getstatic 226 com/parse/ParseObject:isCreatingPointerForObjectId Ljava/lang/ThreadLocal;
// 78: aconst_null
// 79: invokevirtual 588 java/lang/ThreadLocal:set (Ljava/lang/Object;)V
// 82: aload_0
// 83: athrow
// 84: getstatic 226 com/parse/ParseObject:isCreatingPointerForObjectId Ljava/lang/ThreadLocal;
// 87: aload_1
// 88: invokevirtual 588 java/lang/ThreadLocal:set (Ljava/lang/Object;)V
// 91: goto -74 -> 17
// 94: astore_0
// 95: new 494 java/lang/RuntimeException
// 98: dup
// 99: ldc_w 576
// 102: aload_0
// 103: invokespecial 579 java/lang/RuntimeException:<init> (Ljava/lang/String;Ljava/lang/Throwable;)V
// 106: athrow
// 107: getstatic 226 com/parse/ParseObject:isCreatingPointerForObjectId Ljava/lang/ThreadLocal;
// 110: aconst_null
// 111: invokevirtual 588 java/lang/ThreadLocal:set (Ljava/lang/Object;)V
// 114: aload_1
// 115: areturn
// Local variable table:
// start length slot name signature
// 0 116 0 paramString1 String
// 0 116 1 paramString2 String
// 20 23 2 localObject1 Object
// 18 9 3 localObject2 Object
// 3 30 4 localOfflineStore OfflineStore
// Exception table:
// from to target type
// 9 17 71 java/lang/RuntimeException
// 32 40 71 java/lang/RuntimeException
// 46 51 71 java/lang/RuntimeException
// 53 71 71 java/lang/RuntimeException
// 84 91 71 java/lang/RuntimeException
// 9 17 74 finally
// 32 40 74 finally
// 46 51 74 finally
// 53 71 74 finally
// 72 74 74 finally
// 84 91 74 finally
// 95 107 74 finally
// 9 17 94 java/lang/Exception
// 32 40 94 java/lang/Exception
// 46 51 94 java/lang/Exception
// 53 71 94 java/lang/Exception
// 84 91 94 java/lang/Exception
}
private ParseOperationSet currentOperations()
{
synchronized (this.mutex)
{
ParseOperationSet localParseOperationSet = (ParseOperationSet)this.operationSetQueue.getLast();
return localParseOperationSet;
}
}
private ParseRESTObjectCommand currentSaveEventuallyCommand(ParseOperationSet paramParseOperationSet, ParseEncoder paramParseEncoder, String paramString)
throws ParseException
{
State localState = getState();
paramParseOperationSet = ParseRESTObjectCommand.saveObjectCommand(localState, toJSONObjectForSaving(localState, paramParseOperationSet, paramParseEncoder), paramString);
paramParseOperationSet.enableRetrying();
return paramParseOperationSet;
}
private static Task<Void> deepSaveAsync(final Object paramObject, final String paramString)
{
Object localObject1 = new HashSet();
Object localObject3 = new HashSet();
collectDirtyChildren(paramObject, (Collection)localObject1, (Collection)localObject3);
Object localObject2 = new HashSet();
paramObject = ((Set)localObject1).iterator();
while (((Iterator)paramObject).hasNext())
{
localObject4 = (ParseObject)((Iterator)paramObject).next();
if (((localObject4 instanceof ParseUser)) && (((ParseUser)localObject4).isLazy())) {
((Set)localObject2).add((ParseUser)localObject4);
}
}
((Set)localObject1).removeAll((Collection)localObject2);
paramObject = new AtomicBoolean(false);
final Object localObject4 = new ArrayList();
localObject3 = ((Set)localObject3).iterator();
while (((Iterator)localObject3).hasNext()) {
((List)localObject4).add(((ParseFile)((Iterator)localObject3).next()).saveAsync(paramString, null, null));
}
localObject3 = Task.whenAll((Collection)localObject4).continueWith(new Continuation()
{
public Void then(Task<Void> paramAnonymousTask)
throws Exception
{
this.val$filesComplete.set(true);
return null;
}
});
localObject4 = new AtomicBoolean(false);
ArrayList localArrayList = new ArrayList();
localObject2 = ((Set)localObject2).iterator();
while (((Iterator)localObject2).hasNext()) {
localArrayList.add(((ParseUser)((Iterator)localObject2).next()).saveAsync(paramString));
}
localObject2 = Task.whenAll(localArrayList).continueWith(new Continuation()
{
public Void then(Task<Void> paramAnonymousTask)
throws Exception
{
this.val$usersComplete.set(true);
return null;
}
});
localObject1 = new Capture(localObject1);
Task.whenAll(Arrays.asList(new Task[] { localObject3, localObject2, Task.forResult(null).continueWhile(new Callable()new Continuation
{
public Boolean call()
throws Exception
{
if (((Set)this.val$remaining.get()).size() > 0) {}
for (boolean bool = true;; bool = false) {
return Boolean.valueOf(bool);
}
}
}, new Continuation()
{
public Task<Void> then(final Task<Void> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = new ArrayList();
HashSet localHashSet = new HashSet();
Iterator localIterator = ((Set)this.val$remaining.get()).iterator();
while (localIterator.hasNext())
{
ParseObject localParseObject = (ParseObject)localIterator.next();
if (localParseObject.canBeSerialized()) {
paramAnonymousTask.add(localParseObject);
} else {
localHashSet.add(localParseObject);
}
}
this.val$remaining.set(localHashSet);
if ((paramAnonymousTask.size() == 0) && (paramObject.get()) && (localObject4.get())) {
throw new RuntimeException("Unable to save a ParseObject with a relation to a cycle.");
}
if (paramAnonymousTask.size() == 0) {
return Task.forResult(null);
}
ParseObject.enqueueForAll(paramAnonymousTask, new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymous2Task)
throws Exception
{
return ParseObject.saveAllAsync(paramAnonymousTask, ParseObject.41.this.val$sessionToken, paramAnonymous2Task);
}
});
}
}) }));
}
public static <T extends ParseObject> void deleteAll(List<T> paramList)
throws ParseException
{
ParseTaskUtils.wait(deleteAllInBackground(paramList));
}
private static <T extends ParseObject> Task<Void> deleteAllAsync(List<T> paramList, final String paramString)
{
if (paramList.size() == 0) {
return Task.forResult(null);
}
int j = paramList.size();
ArrayList localArrayList = new ArrayList(j);
HashSet localHashSet = new HashSet();
int i = 0;
while (i < j)
{
ParseObject localParseObject = (ParseObject)paramList.get(i);
if (!localHashSet.contains(localParseObject.getObjectId()))
{
localHashSet.add(localParseObject.getObjectId());
localArrayList.add(localParseObject);
}
i += 1;
}
enqueueForAll(localArrayList, new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
return ParseObject.deleteAllAsync(this.val$uniqueObjects, paramString, paramAnonymousTask);
}
});
}
private static <T extends ParseObject> Task<Void> deleteAllAsync(List<T> paramList, final String paramString, Task<Void> paramTask)
{
paramTask.continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
int j = this.val$uniqueObjects.size();
paramAnonymousTask = new ArrayList(j);
int i = 0;
while (i < j)
{
localObject = (ParseObject)this.val$uniqueObjects.get(i);
((ParseObject)localObject).validateDelete();
paramAnonymousTask.add(((ParseObject)localObject).getState());
i += 1;
}
paramAnonymousTask = ParseObject.access$800().deleteAllAsync(paramAnonymousTask, paramString);
Object localObject = new ArrayList(j);
i = 0;
while (i < j)
{
((List)localObject).add(((Task)paramAnonymousTask.get(i)).onSuccessTask(new Continuation()
{
public Task<Void> then(final Task<Void> paramAnonymous2Task)
throws Exception
{
this.val$object.handleDeleteResultAsync().continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymous3Task)
throws Exception
{
return paramAnonymous2Task;
}
});
}
}));
i += 1;
}
return Task.whenAll((Collection)localObject);
}
});
}
public static <T extends ParseObject> Task<Void> deleteAllInBackground(List<T> paramList)
{
ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation()
{
public Task<Void> then(Task<String> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (String)paramAnonymousTask.getResult();
return ParseObject.deleteAllAsync(this.val$objects, paramAnonymousTask);
}
});
}
public static <T extends ParseObject> void deleteAllInBackground(List<T> paramList, DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(deleteAllInBackground(paramList), paramDeleteCallback);
}
private Task<Void> deleteAsync(final String paramString, Task<Void> paramTask)
{
validateDelete();
paramTask.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
if (ParseObject.this.state.objectId() == null) {
return paramAnonymousTask.cast();
}
return ParseObject.this.deleteAsync(paramString);
}
}).onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
return ParseObject.this.handleDeleteResultAsync();
}
});
}
/* Error */
static <T> Task<T> enqueueForAll(List<? extends ParseObject> paramList, final Continuation<Void, Task<T>> paramContinuation)
{
// Byte code:
// 0: invokestatic 760 bolts/Task:create ()Lbolts/Task$TaskCompletionSource;
// 3: astore_3
// 4: new 641 java/util/ArrayList
// 7: dup
// 8: aload_0
// 9: invokeinterface 706 1 0
// 14: invokespecial 709 java/util/ArrayList:<init> (I)V
// 17: astore_2
// 18: aload_0
// 19: invokeinterface 761 1 0
// 24: astore 4
// 26: aload 4
// 28: invokeinterface 431 1 0
// 33: ifeq +29 -> 62
// 36: aload_2
// 37: aload 4
// 39: invokeinterface 434 1 0
// 44: checkcast 2 com/parse/ParseObject
// 47: getfield 238 com/parse/ParseObject:taskQueue Lcom/parse/TaskQueue;
// 50: invokevirtual 765 com/parse/TaskQueue:getLock ()Ljava/util/concurrent/locks/Lock;
// 53: invokeinterface 651 2 0
// 58: pop
// 59: goto -33 -> 26
// 62: new 767 com/parse/LockSet
// 65: dup
// 66: aload_2
// 67: invokespecial 770 com/parse/LockSet:<init> (Ljava/util/Collection;)V
// 70: astore_2
// 71: aload_2
// 72: invokevirtual 773 com/parse/LockSet:lock ()V
// 75: aload_1
// 76: aload_3
// 77: invokevirtual 778 bolts/Task$TaskCompletionSource:getTask ()Lbolts/Task;
// 80: invokeinterface 783 2 0
// 85: checkcast 653 bolts/Task
// 88: astore_1
// 89: new 641 java/util/ArrayList
// 92: dup
// 93: invokespecial 642 java/util/ArrayList:<init> ()V
// 96: astore 4
// 98: aload_0
// 99: invokeinterface 761 1 0
// 104: astore_0
// 105: aload_0
// 106: invokeinterface 431 1 0
// 111: ifeq +52 -> 163
// 114: aload_0
// 115: invokeinterface 434 1 0
// 120: checkcast 2 com/parse/ParseObject
// 123: getfield 238 com/parse/ParseObject:taskQueue Lcom/parse/TaskQueue;
// 126: new 34 com/parse/ParseObject$2
// 129: dup
// 130: aload 4
// 132: aload_1
// 133: invokespecial 786 com/parse/ParseObject$2:<init> (Ljava/util/List;Lbolts/Task;)V
// 136: invokevirtual 789 com/parse/TaskQueue:enqueue (Lbolts/Continuation;)Lbolts/Task;
// 139: pop
// 140: goto -35 -> 105
// 143: astore_0
// 144: aload_2
// 145: invokevirtual 792 com/parse/LockSet:unlock ()V
// 148: aload_0
// 149: athrow
// 150: astore_0
// 151: aload_0
// 152: athrow
// 153: astore_0
// 154: new 494 java/lang/RuntimeException
// 157: dup
// 158: aload_0
// 159: invokespecial 497 java/lang/RuntimeException:<init> (Ljava/lang/Throwable;)V
// 162: athrow
// 163: aload 4
// 165: invokestatic 657 bolts/Task:whenAll (Ljava/util/Collection;)Lbolts/Task;
// 168: new 60 com/parse/ParseObject$3
// 171: dup
// 172: aload_3
// 173: invokespecial 795 com/parse/ParseObject$3:<init> (Lbolts/Task$TaskCompletionSource;)V
// 176: invokevirtual 664 bolts/Task:continueWith (Lbolts/Continuation;)Lbolts/Task;
// 179: pop
// 180: aload_2
// 181: invokevirtual 792 com/parse/LockSet:unlock ()V
// 184: aload_1
// 185: areturn
// Local variable table:
// start length slot name signature
// 0 186 0 paramList List<? extends ParseObject>
// 0 186 1 paramContinuation Continuation<Void, Task<T>>
// 17 164 2 localObject1 Object
// 3 170 3 localTaskCompletionSource Task.TaskCompletionSource
// 24 140 4 localObject2 Object
// Exception table:
// from to target type
// 75 89 143 finally
// 89 105 143 finally
// 105 140 143 finally
// 151 153 143 finally
// 154 163 143 finally
// 163 180 143 finally
// 75 89 150 java/lang/RuntimeException
// 75 89 153 java/lang/Exception
}
private Task<Void> enqueueSaveEventuallyOperationAsync(final ParseOperationSet paramParseOperationSet)
{
if (!paramParseOperationSet.isSaveEventually()) {
throw new IllegalStateException("This should only be used to enqueue saveEventually operation sets");
}
this.taskQueue.enqueue(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
paramAnonymousTask.continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymous2Task)
throws Exception
{
return Parse.getEventuallyQueue().waitForOperationSetAndEventuallyPin(ParseObject.15.this.val$operationSet, null).makeVoid();
}
});
}
});
}
public static <T extends ParseObject> List<T> fetchAll(List<T> paramList)
throws ParseException
{
return (List)ParseTaskUtils.wait(fetchAllInBackground(paramList));
}
private static <T extends ParseObject> Task<List<T>> fetchAllAsync(List<T> paramList, final ParseUser paramParseUser, final boolean paramBoolean, Task<Void> paramTask)
{
if (paramList.size() == 0) {
return Task.forResult(paramList);
}
ArrayList localArrayList = new ArrayList();
Object localObject = null;
Iterator localIterator = paramList.iterator();
while (localIterator.hasNext())
{
ParseObject localParseObject = (ParseObject)localIterator.next();
if ((!paramBoolean) || (!localParseObject.isDataAvailable()))
{
if ((localObject != null) && (!localParseObject.getClassName().equals(localObject))) {
throw new IllegalArgumentException("All objects should have the same class");
}
localObject = localParseObject.getClassName();
if (localParseObject.getObjectId() != null) {
localArrayList.add(localParseObject.getObjectId());
} else if (!paramBoolean) {
throw new IllegalArgumentException("All objects must exist on the server");
}
}
}
if (localArrayList.size() == 0) {
return Task.forResult(paramList);
}
paramTask.continueWithTask(new Continuation()
{
public Task<List<T>> then(Task<Void> paramAnonymousTask)
throws Exception
{
return this.val$query.findAsync(this.val$query.getBuilder().build(), paramParseUser, null);
}
}).onSuccess(new Continuation()
{
public List<T> then(Task<List<T>> paramAnonymousTask)
throws Exception
{
HashMap localHashMap = new HashMap();
paramAnonymousTask = ((List)paramAnonymousTask.getResult()).iterator();
ParseObject localParseObject1;
while (paramAnonymousTask.hasNext())
{
localParseObject1 = (ParseObject)paramAnonymousTask.next();
localHashMap.put(localParseObject1.getObjectId(), localParseObject1);
}
paramAnonymousTask = this.val$objects.iterator();
while (paramAnonymousTask.hasNext())
{
localParseObject1 = (ParseObject)paramAnonymousTask.next();
if ((!paramBoolean) || (!localParseObject1.isDataAvailable()))
{
ParseObject localParseObject2 = (ParseObject)localHashMap.get(localParseObject1.getObjectId());
if (localParseObject2 == null) {
throw new ParseException(101, "Object id " + localParseObject1.getObjectId() + " does not exist");
}
if (!Parse.isLocalDatastoreEnabled()) {
localParseObject1.mergeFromObject(localParseObject2);
}
}
}
return this.val$objects;
}
});
}
private static <T extends ParseObject> Task<List<T>> fetchAllAsync(List<T> paramList, final boolean paramBoolean)
{
ParseUser.getCurrentUserAsync().onSuccessTask(new Continuation()
{
public Task<List<T>> then(final Task<ParseUser> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (ParseUser)paramAnonymousTask.getResult();
ParseObject.enqueueForAll(this.val$objects, new Continuation()
{
public Task<List<T>> then(Task<Void> paramAnonymous2Task)
throws Exception
{
return ParseObject.fetchAllAsync(ParseObject.45.this.val$objects, paramAnonymousTask, ParseObject.45.this.val$onlyIfNeeded, paramAnonymous2Task);
}
});
}
});
}
public static <T extends ParseObject> List<T> fetchAllIfNeeded(List<T> paramList)
throws ParseException
{
return (List)ParseTaskUtils.wait(fetchAllIfNeededInBackground(paramList));
}
public static <T extends ParseObject> Task<List<T>> fetchAllIfNeededInBackground(List<T> paramList)
{
return fetchAllAsync(paramList, true);
}
public static <T extends ParseObject> void fetchAllIfNeededInBackground(List<T> paramList, FindCallback<T> paramFindCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(fetchAllIfNeededInBackground(paramList), paramFindCallback);
}
public static <T extends ParseObject> Task<List<T>> fetchAllInBackground(List<T> paramList)
{
return fetchAllAsync(paramList, false);
}
public static <T extends ParseObject> void fetchAllInBackground(List<T> paramList, FindCallback<T> paramFindCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(fetchAllInBackground(paramList), paramFindCallback);
}
static <T extends ParseObject> T from(State paramState)
{
ParseObject localParseObject = createWithoutData(paramState.className(), paramState.objectId());
synchronized (localParseObject.mutex)
{
if (paramState.isComplete())
{
localParseObject.setState(paramState);
return localParseObject;
}
paramState = localParseObject.getState().newBuilder().apply(paramState).build();
}
}
static <T extends ParseObject> T fromJSON(JSONObject paramJSONObject, String paramString, boolean paramBoolean)
{
return fromJSON(paramJSONObject, paramString, paramBoolean, ParseDecoder.get());
}
static <T extends ParseObject> T fromJSON(JSONObject paramJSONObject, String paramString, boolean paramBoolean, ParseDecoder paramParseDecoder)
{
paramString = paramJSONObject.optString("className", paramString);
if (paramString == null) {
return null;
}
paramString = createWithoutData(paramString, paramJSONObject.optString("objectId", null));
paramString.setState(paramString.mergeFromServer(paramString.getState(), paramJSONObject, paramParseDecoder, paramBoolean));
return paramString;
}
static <T extends ParseObject> T fromJSONPayload(JSONObject paramJSONObject, ParseDecoder paramParseDecoder)
{
Object localObject = paramJSONObject.optString("className");
if ((localObject == null) || (ParseTextUtils.isEmpty((CharSequence)localObject))) {
return null;
}
localObject = createWithoutData((String)localObject, paramJSONObject.optString("objectId", null));
((ParseObject)localObject).build(paramJSONObject, paramParseDecoder);
return (T)localObject;
}
private ParseACL getACL(boolean paramBoolean)
{
synchronized (this.mutex)
{
checkGetAccess("ACL");
Object localObject2 = this.estimatedData.get("ACL");
if (localObject2 == null) {
return null;
}
if (!(localObject2 instanceof ParseACL)) {
throw new RuntimeException("only ACLs can be stored in the ACL key");
}
}
if ((paramBoolean) && (((ParseACL)localObject3).isShared()))
{
localParseACL = ((ParseACL)localObject3).copy();
this.estimatedData.put("ACL", localParseACL);
addToHashedObjects(localParseACL);
return localParseACL;
}
ParseACL localParseACL = (ParseACL)localParseACL;
return localParseACL;
}
static String getClassName(Class<? extends ParseObject> paramClass)
{
String str = (String)classNames.get(paramClass);
Object localObject = str;
if (str == null)
{
localObject = (ParseClassName)paramClass.getAnnotation(ParseClassName.class);
if (localObject == null) {
return null;
}
localObject = ((ParseClassName)localObject).value();
classNames.put(paramClass, localObject);
}
return (String)localObject;
}
private static LocalIdManager getLocalIdManager()
{
return ParseCorePlugins.getInstance().getLocalIdManager();
}
private static ParseObjectController getObjectController()
{
return ParseCorePlugins.getInstance().getObjectController();
}
private boolean hasDirtyChildren()
{
for (;;)
{
synchronized (this.mutex)
{
ArrayList localArrayList = new ArrayList();
collectDirtyChildren(this.estimatedData, localArrayList, null);
if (localArrayList.size() > 0)
{
bool = true;
return bool;
}
}
boolean bool = false;
}
}
private static boolean isAccessible(Member paramMember)
{
return (Modifier.isPublic(paramMember.getModifiers())) || ((paramMember.getDeclaringClass().getPackage().getName().equals("com.parse")) && (!Modifier.isPrivate(paramMember.getModifiers())) && (!Modifier.isProtected(paramMember.getModifiers())));
}
private void notifyObjectIdChanged(String paramString1, String paramString2)
{
synchronized (this.mutex)
{
OfflineStore localOfflineStore = Parse.getLocalDatastore();
if (localOfflineStore != null) {
localOfflineStore.updateObjectId(this, paramString1, paramString2);
}
if (this.localId != null)
{
getLocalIdManager().setObjectId(this.localId, paramString2);
this.localId = null;
}
return;
}
}
public static <T extends ParseObject> void pinAll(String paramString, List<T> paramList)
throws ParseException
{
ParseTaskUtils.wait(pinAllInBackground(paramString, paramList));
}
public static <T extends ParseObject> void pinAll(List<T> paramList)
throws ParseException
{
ParseTaskUtils.wait(pinAllInBackground("_default", paramList));
}
public static <T extends ParseObject> Task<Void> pinAllInBackground(String paramString, List<T> paramList)
{
return pinAllInBackground(paramString, paramList, true);
}
private static <T extends ParseObject> Task<Void> pinAllInBackground(String paramString, final List<T> paramList, final boolean paramBoolean)
{
if (!Parse.isLocalDatastoreEnabled()) {
throw new IllegalStateException("Method requires Local Datastore. Please refer to `Parse#enableLocalDatastore(Context)`.");
}
Task localTask = Task.forResult(null);
Iterator localIterator = paramList.iterator();
while (localIterator.hasNext()) {
localTask = localTask.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
if (!this.val$object.isDataAvailable("ACL")) {
return Task.forResult(null);
}
paramAnonymousTask = this.val$object.getACL(false);
if (paramAnonymousTask == null) {
return Task.forResult(null);
}
paramAnonymousTask = paramAnonymousTask.getUnresolvedUser();
if ((paramAnonymousTask == null) || (!paramAnonymousTask.isCurrentUser())) {
return Task.forResult(null);
}
return ParseUser.pinCurrentUserIfNeededAsync(paramAnonymousTask);
}
});
}
localTask.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
OfflineStore localOfflineStore = Parse.getLocalDatastore();
if (this.val$name != null) {}
for (paramAnonymousTask = this.val$name;; paramAnonymousTask = "_default") {
return localOfflineStore.pinAllObjectsAsync(paramAnonymousTask, paramList, paramBoolean);
}
}
}).onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
if ("_currentUser".equals(this.val$name)) {}
Object localObject;
do
{
do
{
Iterator localIterator;
while (!localIterator.hasNext())
{
return paramAnonymousTask;
localIterator = paramList.iterator();
}
localObject = (ParseObject)localIterator.next();
} while (!(localObject instanceof ParseUser));
localObject = (ParseUser)localObject;
} while (!((ParseUser)localObject).isCurrentUser());
return ParseUser.pinCurrentUserIfNeededAsync((ParseUser)localObject);
}
});
}
public static <T extends ParseObject> Task<Void> pinAllInBackground(List<T> paramList)
{
return pinAllInBackground("_default", paramList);
}
public static <T extends ParseObject> void pinAllInBackground(String paramString, List<T> paramList, SaveCallback paramSaveCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(pinAllInBackground(paramString, paramList), paramSaveCallback);
}
public static <T extends ParseObject> void pinAllInBackground(List<T> paramList, SaveCallback paramSaveCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(pinAllInBackground("_default", paramList), paramSaveCallback);
}
private void rebuildEstimatedData()
{
synchronized (this.mutex)
{
this.estimatedData.clear();
Iterator localIterator1 = this.state.keySet().iterator();
if (localIterator1.hasNext())
{
String str = (String)localIterator1.next();
this.estimatedData.put(str, this.state.get(str));
}
}
Iterator localIterator2 = this.operationSetQueue.iterator();
while (localIterator2.hasNext()) {
applyOperations((ParseOperationSet)localIterator2.next(), this.estimatedData);
}
}
static void registerParseSubclasses()
{
registerSubclass(ParseUser.class);
registerSubclass(ParseRole.class);
registerSubclass(ParseInstallation.class);
registerSubclass(ParseSession.class);
registerSubclass(ParsePin.class);
registerSubclass(EventuallyPin.class);
}
public static void registerSubclass(Class<? extends ParseObject> paramClass)
{
String str = getClassName(paramClass);
if (str == null) {
throw new IllegalArgumentException("No ParseClassName annotation provided on " + paramClass);
}
if (paramClass.getDeclaredConstructors().length > 0) {
try
{
if (!isAccessible(paramClass.getDeclaredConstructor(new Class[0]))) {
throw new IllegalArgumentException("Default constructor for " + paramClass + " is not accessible.");
}
}
catch (NoSuchMethodException localNoSuchMethodException)
{
throw new IllegalArgumentException("No default constructor provided for " + paramClass);
}
}
Class localClass = (Class)objectTypes.get(localNoSuchMethodException);
if ((localClass != null) && (paramClass.isAssignableFrom(localClass))) {}
do
{
do
{
return;
objectTypes.put(localNoSuchMethodException, paramClass);
} while ((localClass == null) || (paramClass.equals(localClass)));
if (localNoSuchMethodException.equals(getClassName(ParseUser.class)))
{
ParseUser.getCurrentUserController().clearFromMemory();
return;
}
} while (!localNoSuchMethodException.equals(getClassName(ParseInstallation.class)));
ParseInstallation.getCurrentInstallationController().clearFromMemory();
}
public static <T extends ParseObject> void saveAll(List<T> paramList)
throws ParseException
{
ParseTaskUtils.wait(saveAllInBackground(paramList));
}
private static <T extends ParseObject> Task<Void> saveAllAsync(List<T> paramList, final String paramString, Task<Void> paramTask)
{
paramTask.continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
int j = this.val$uniqueObjects.size();
Object localObject = new ArrayList(j);
paramAnonymousTask = new ArrayList(j);
ArrayList localArrayList = new ArrayList(j);
int i = 0;
while (i < j)
{
ParseObject localParseObject = (ParseObject)this.val$uniqueObjects.get(i);
localParseObject.updateBeforeSave();
localParseObject.validateSave();
((List)localObject).add(localParseObject.getState());
paramAnonymousTask.add(localParseObject.startSave());
localArrayList.add(new KnownParseObjectDecoder(localParseObject.collectFetchedObjects()));
i += 1;
}
localObject = ParseObject.access$800().saveAllAsync((List)localObject, paramAnonymousTask, paramString, localArrayList);
localArrayList = new ArrayList(j);
i = 0;
while (i < j)
{
localArrayList.add(((Task)((List)localObject).get(i)).continueWithTask(new Continuation()
{
public Task<Void> then(final Task<ParseObject.State> paramAnonymous2Task)
throws Exception
{
ParseObject.State localState = (ParseObject.State)paramAnonymous2Task.getResult();
this.val$object.handleSaveResultAsync(localState, this.val$operations).continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymous3Task)
throws Exception
{
if ((paramAnonymous3Task.isFaulted()) || (paramAnonymous3Task.isCancelled())) {
return paramAnonymous3Task;
}
return paramAnonymous2Task.makeVoid();
}
});
}
}));
i += 1;
}
return Task.whenAll(localArrayList);
}
});
}
public static <T extends ParseObject> Task<Void> saveAllInBackground(List<T> paramList)
{
ParseUser.getCurrentUserAsync().onSuccessTask(new Continuation()
{
public Task<String> then(Task<ParseUser> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (ParseUser)paramAnonymousTask.getResult();
if (paramAnonymousTask == null) {
return Task.forResult(null);
}
if (!paramAnonymousTask.isLazy()) {
return Task.forResult(paramAnonymousTask.getSessionToken());
}
paramAnonymousTask = this.val$objects.iterator();
while (paramAnonymousTask.hasNext())
{
final Object localObject = (ParseObject)paramAnonymousTask.next();
if (((ParseObject)localObject).isDataAvailable("ACL"))
{
localObject = ((ParseObject)localObject).getACL(false);
if (localObject != null)
{
final ParseUser localParseUser = ((ParseACL)localObject).getUnresolvedUser();
if ((localParseUser != null) && (localParseUser.isCurrentUser())) {
localParseUser.saveAsync(null).onSuccess(new Continuation()
{
public String then(Task<Void> paramAnonymous2Task)
throws Exception
{
if (localObject.hasUnresolvedUser()) {
throw new IllegalStateException("ACL has an unresolved ParseUser. Save or sign up before attempting to serialize the ACL.");
}
return localParseUser.getSessionToken();
}
});
}
}
}
}
return Task.forResult(null);
}
}).onSuccessTask(new Continuation()
{
public Task<Void> then(Task<String> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (String)paramAnonymousTask.getResult();
return ParseObject.deepSaveAsync(this.val$objects, paramAnonymousTask);
}
});
}
public static <T extends ParseObject> void saveAllInBackground(List<T> paramList, SaveCallback paramSaveCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(saveAllInBackground(paramList), paramSaveCallback);
}
private void setState(State paramState, boolean paramBoolean)
{
synchronized (this.mutex)
{
String str1 = this.state.objectId();
String str2 = paramState.objectId();
this.state = paramState;
if ((paramBoolean) && (!ParseTextUtils.equals(str1, str2))) {
notifyObjectIdChanged(str1, str2);
}
rebuildEstimatedData();
checkpointAllMutableContainers();
return;
}
}
public static void unpinAll()
throws ParseException
{
ParseTaskUtils.wait(unpinAllInBackground());
}
public static void unpinAll(String paramString)
throws ParseException
{
ParseTaskUtils.wait(unpinAllInBackground(paramString));
}
public static <T extends ParseObject> void unpinAll(String paramString, List<T> paramList)
throws ParseException
{
ParseTaskUtils.wait(unpinAllInBackground(paramString, paramList));
}
public static <T extends ParseObject> void unpinAll(List<T> paramList)
throws ParseException
{
ParseTaskUtils.wait(unpinAllInBackground("_default", paramList));
}
public static Task<Void> unpinAllInBackground()
{
return unpinAllInBackground("_default");
}
public static Task<Void> unpinAllInBackground(String paramString)
{
if (!Parse.isLocalDatastoreEnabled()) {
throw new IllegalStateException("Method requires Local Datastore. Please refer to `Parse#enableLocalDatastore(Context)`.");
}
String str = paramString;
if (paramString == null) {
str = "_default";
}
return Parse.getLocalDatastore().unpinAllObjectsAsync(str);
}
public static <T extends ParseObject> Task<Void> unpinAllInBackground(String paramString, List<T> paramList)
{
if (!Parse.isLocalDatastoreEnabled()) {
throw new IllegalStateException("Method requires Local Datastore. Please refer to `Parse#enableLocalDatastore(Context)`.");
}
String str = paramString;
if (paramString == null) {
str = "_default";
}
return Parse.getLocalDatastore().unpinAllObjectsAsync(str, paramList);
}
public static <T extends ParseObject> Task<Void> unpinAllInBackground(List<T> paramList)
{
return unpinAllInBackground("_default", paramList);
}
public static void unpinAllInBackground(DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(unpinAllInBackground(), paramDeleteCallback);
}
public static void unpinAllInBackground(String paramString, DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(unpinAllInBackground(paramString), paramDeleteCallback);
}
public static <T extends ParseObject> void unpinAllInBackground(String paramString, List<T> paramList, DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(unpinAllInBackground(paramString, paramList), paramDeleteCallback);
}
public static <T extends ParseObject> void unpinAllInBackground(List<T> paramList, DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(unpinAllInBackground("_default", paramList), paramDeleteCallback);
}
static void unregisterParseSubclasses()
{
unregisterSubclass(ParseUser.class);
unregisterSubclass(ParseRole.class);
unregisterSubclass(ParseInstallation.class);
unregisterSubclass(ParseSession.class);
unregisterSubclass(ParsePin.class);
unregisterSubclass(EventuallyPin.class);
}
static void unregisterSubclass(Class<? extends ParseObject> paramClass)
{
unregisterSubclass(getClassName(paramClass));
}
static void unregisterSubclass(String paramString)
{
objectTypes.remove(paramString);
}
public void add(String paramString, Object paramObject)
{
addAll(paramString, Arrays.asList(new Object[] { paramObject }));
}
public void addAll(String paramString, Collection<?> paramCollection)
{
performOperation(paramString, new ParseAddOperation(paramCollection));
}
public void addAllUnique(String paramString, Collection<?> paramCollection)
{
performOperation(paramString, new ParseAddUniqueOperation(paramCollection));
}
public void addUnique(String paramString, Object paramObject)
{
addAllUnique(paramString, Arrays.asList(new Object[] { paramObject }));
}
void build(JSONObject paramJSONObject, ParseDecoder paramParseDecoder)
{
ParseObject.State.Builder localBuilder;
for (;;)
{
String str;
try
{
localBuilder = (ParseObject.State.Builder)new ParseObject.State.Builder(this.state).isComplete(true);
localBuilder.clear();
Iterator localIterator = paramJSONObject.keys();
if (!localIterator.hasNext()) {
break;
}
str = (String)localIterator.next();
if (str.equals("className")) {
continue;
}
if (str.equals("objectId"))
{
localBuilder.objectId(paramJSONObject.getString(str));
continue;
}
if (!str.equals("createdAt")) {
break label126;
}
}
catch (JSONException paramJSONObject)
{
throw new RuntimeException(paramJSONObject);
}
localBuilder.createdAt(ParseDateFormat.getInstance().parse(paramJSONObject.getString(str)));
continue;
label126:
if (str.equals("updatedAt"))
{
localBuilder.updatedAt(ParseDateFormat.getInstance().parse(paramJSONObject.getString(str)));
}
else
{
Object localObject = paramParseDecoder.decode(paramJSONObject.get(str));
if ((localObject instanceof ParseFieldOperation)) {
performOperation(str, (ParseFieldOperation)localObject);
} else {
put(str, localObject);
}
}
}
setState(localBuilder.build());
}
void checkForChangesToMutableContainers()
{
synchronized (this.mutex)
{
Iterator localIterator = this.estimatedData.keySet().iterator();
if (localIterator.hasNext())
{
String str = (String)localIterator.next();
checkForChangesToMutableContainer(str, this.estimatedData.get(str));
}
}
this.hashedObjects.keySet().retainAll(this.estimatedData.values());
}
public boolean containsKey(String paramString)
{
synchronized (this.mutex)
{
boolean bool = this.estimatedData.containsKey(paramString);
return bool;
}
}
void copyChangesFrom(ParseObject paramParseObject)
{
synchronized (this.mutex)
{
paramParseObject = (ParseOperationSet)paramParseObject.operationSetQueue.getFirst();
Iterator localIterator = paramParseObject.keySet().iterator();
if (localIterator.hasNext())
{
String str = (String)localIterator.next();
performOperation(str, (ParseFieldOperation)paramParseObject.get(str));
}
}
}
public final void delete()
throws ParseException
{
ParseTaskUtils.wait(deleteInBackground());
}
Task<Void> deleteAsync(String paramString)
throws ParseException
{
return getObjectController().deleteAsync(getState(), paramString);
}
public final Task<Void> deleteEventually()
{
synchronized (this.mutex)
{
validateDelete();
this.isDeletingEventually += 1;
Object localObject1 = null;
if (getObjectId() == null) {
localObject1 = getOrCreateLocalId();
}
Object localObject4 = ParseUser.getCurrentSessionToken();
localObject4 = ParseRESTObjectCommand.deleteObjectCommand(getState(), (String)localObject4);
((ParseRESTCommand)localObject4).enableRetrying();
((ParseRESTCommand)localObject4).setLocalId((String)localObject1);
localObject1 = Parse.getEventuallyQueue().enqueueEventuallyAsync((ParseRESTCommand)localObject4, this);
if (Parse.isLocalDatastoreEnabled()) {
return ((Task)localObject1).makeVoid();
}
}
((Task)localObject2).onSuccessTask(new Continuation()
{
public Task<Void> then(Task<JSONObject> paramAnonymousTask)
throws Exception
{
return ParseObject.this.handleDeleteEventuallyResultAsync();
}
});
}
public final void deleteEventually(DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(deleteEventually(), paramDeleteCallback);
}
public final Task<Void> deleteInBackground()
{
ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation()
{
public Task<Void> then(final Task<String> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (String)paramAnonymousTask.getResult();
ParseObject.this.taskQueue.enqueue(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymous2Task)
throws Exception
{
return ParseObject.this.deleteAsync(paramAnonymousTask, paramAnonymous2Task);
}
});
}
});
}
public final void deleteInBackground(DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(deleteInBackground(), paramDeleteCallback);
}
public <T extends ParseObject> T fetch()
throws ParseException
{
return (ParseObject)ParseTaskUtils.wait(fetchInBackground());
}
<T extends ParseObject> Task<T> fetchAsync(final String paramString, Task<Void> paramTask)
{
paramTask.onSuccessTask(new Continuation()
{
public Task<ParseObject.State> then(Task<Void> arg1)
throws Exception
{
synchronized (ParseObject.this.mutex)
{
ParseObject.State localState = ParseObject.this.getState();
Map localMap = ParseObject.this.collectFetchedObjects();
??? = new KnownParseObjectDecoder(localMap);
return ParseObject.access$800().fetchAsync(localState, paramString, ???);
}
}
}).onSuccessTask(new Continuation()
{
public Task<Void> then(Task<ParseObject.State> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (ParseObject.State)paramAnonymousTask.getResult();
return ParseObject.this.handleFetchResultAsync(paramAnonymousTask);
}
}).onSuccess(new Continuation()
{
public T then(Task<Void> paramAnonymousTask)
throws Exception
{
return ParseObject.this;
}
});
}
public void fetchFromLocalDatastore()
throws ParseException
{
ParseTaskUtils.wait(fetchFromLocalDatastoreAsync());
}
<T extends ParseObject> Task<T> fetchFromLocalDatastoreAsync()
{
if (!Parse.isLocalDatastoreEnabled()) {
throw new IllegalStateException("Method requires Local Datastore. Please refer to `Parse#enableLocalDatastore(Context)`.");
}
return Parse.getLocalDatastore().fetchLocallyAsync(this);
}
public <T extends ParseObject> void fetchFromLocalDatastoreInBackground(GetCallback<T> paramGetCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(fetchFromLocalDatastoreAsync(), paramGetCallback);
}
public <T extends ParseObject> T fetchIfNeeded()
throws ParseException
{
return (ParseObject)ParseTaskUtils.wait(fetchIfNeededInBackground());
}
public final <T extends ParseObject> Task<T> fetchIfNeededInBackground()
{
if (isDataAvailable()) {
return Task.forResult(this);
}
ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation()
{
public Task<T> then(final Task<String> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (String)paramAnonymousTask.getResult();
ParseObject.this.taskQueue.enqueue(new Continuation()
{
public Task<T> then(Task<Void> paramAnonymous2Task)
throws Exception
{
if (ParseObject.this.isDataAvailable()) {
return Task.forResult(ParseObject.this);
}
return ParseObject.this.fetchAsync(paramAnonymousTask, paramAnonymous2Task);
}
});
}
});
}
public final <T extends ParseObject> void fetchIfNeededInBackground(GetCallback<T> paramGetCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(fetchIfNeededInBackground(), paramGetCallback);
}
public final <T extends ParseObject> Task<T> fetchInBackground()
{
ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation()
{
public Task<T> then(final Task<String> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (String)paramAnonymousTask.getResult();
ParseObject.this.taskQueue.enqueue(new Continuation()
{
public Task<T> then(Task<Void> paramAnonymous2Task)
throws Exception
{
return ParseObject.this.fetchAsync(paramAnonymousTask, paramAnonymous2Task);
}
});
}
});
}
public final <T extends ParseObject> void fetchInBackground(GetCallback<T> paramGetCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(fetchInBackground(), paramGetCallback);
}
public Object get(String paramString)
{
synchronized (this.mutex)
{
if (paramString.equals("ACL"))
{
paramString = getACL();
return paramString;
}
checkGetAccess(paramString);
Object localObject2 = this.estimatedData.get(paramString);
if ((localObject2 instanceof ParseRelation)) {
((ParseRelation)localObject2).ensureParentAndKey(this, paramString);
}
return localObject2;
}
}
public ParseACL getACL()
{
return getACL(true);
}
public boolean getBoolean(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
paramString = this.estimatedData.get(paramString);
if (!(paramString instanceof Boolean)) {
return false;
}
boolean bool = ((Boolean)paramString).booleanValue();
return bool;
}
}
public byte[] getBytes(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
paramString = this.estimatedData.get(paramString);
if (!(paramString instanceof byte[])) {
return null;
}
paramString = (byte[])paramString;
return paramString;
}
}
public String getClassName()
{
synchronized (this.mutex)
{
String str = this.state.className();
return str;
}
}
public Date getCreatedAt()
{
long l = getState().createdAt();
if (l > 0L) {
return new Date(l);
}
return null;
}
public Date getDate(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
paramString = this.estimatedData.get(paramString);
if (!(paramString instanceof Date)) {
return null;
}
paramString = (Date)paramString;
return paramString;
}
}
public double getDouble(String paramString)
{
paramString = getNumber(paramString);
if (paramString == null) {
return 0.0D;
}
return paramString.doubleValue();
}
public int getInt(String paramString)
{
paramString = getNumber(paramString);
if (paramString == null) {
return 0;
}
return paramString.intValue();
}
public JSONArray getJSONArray(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
Object localObject2 = this.estimatedData.get(paramString);
Object localObject1 = localObject2;
if ((localObject2 instanceof List))
{
localObject1 = PointerOrLocalIdEncoder.get().encode(localObject2);
put(paramString, localObject1);
}
if (!(localObject1 instanceof JSONArray)) {
return null;
}
paramString = (JSONArray)localObject1;
return paramString;
}
}
public JSONObject getJSONObject(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
Object localObject2 = this.estimatedData.get(paramString);
Object localObject1 = localObject2;
if ((localObject2 instanceof Map))
{
localObject1 = PointerOrLocalIdEncoder.get().encode(localObject2);
put(paramString, localObject1);
}
if (!(localObject1 instanceof JSONObject)) {
return null;
}
paramString = (JSONObject)localObject1;
return paramString;
}
}
public <T> List<T> getList(String paramString)
{
synchronized (this.mutex)
{
Object localObject2 = this.estimatedData.get(paramString);
Object localObject1 = localObject2;
if ((localObject2 instanceof JSONArray))
{
localObject1 = ParseDecoder.get().convertJSONArrayToList((JSONArray)localObject2);
put(paramString, localObject1);
}
if (!(localObject1 instanceof List)) {
return null;
}
paramString = (List)localObject1;
return paramString;
}
}
public long getLong(String paramString)
{
paramString = getNumber(paramString);
if (paramString == null) {
return 0L;
}
return paramString.longValue();
}
public <V> Map<String, V> getMap(String paramString)
{
synchronized (this.mutex)
{
Object localObject2 = this.estimatedData.get(paramString);
Object localObject1 = localObject2;
if ((localObject2 instanceof JSONObject))
{
localObject1 = ParseDecoder.get().convertJSONObjectToMap((JSONObject)localObject2);
put(paramString, localObject1);
}
if (!(localObject1 instanceof Map)) {
return null;
}
paramString = (Map)localObject1;
return paramString;
}
}
public Number getNumber(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
paramString = this.estimatedData.get(paramString);
if (!(paramString instanceof Number)) {
return null;
}
paramString = (Number)paramString;
return paramString;
}
}
public String getObjectId()
{
synchronized (this.mutex)
{
String str = this.state.objectId();
return str;
}
}
String getOrCreateLocalId()
{
synchronized (this.mutex)
{
if (this.localId != null) {
break label50;
}
if (this.state.objectId() != null) {
throw new IllegalStateException("Attempted to get a localId for an object with an objectId.");
}
}
this.localId = getLocalIdManager().createLocalId();
label50:
String str = this.localId;
return str;
}
public ParseFile getParseFile(String paramString)
{
paramString = get(paramString);
if (!(paramString instanceof ParseFile)) {
return null;
}
return (ParseFile)paramString;
}
public ParseGeoPoint getParseGeoPoint(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
paramString = this.estimatedData.get(paramString);
if (!(paramString instanceof ParseGeoPoint)) {
return null;
}
paramString = (ParseGeoPoint)paramString;
return paramString;
}
}
public ParseObject getParseObject(String paramString)
{
paramString = get(paramString);
if (!(paramString instanceof ParseObject)) {
return null;
}
return (ParseObject)paramString;
}
public ParseUser getParseUser(String paramString)
{
paramString = get(paramString);
if (!(paramString instanceof ParseUser)) {
return null;
}
return (ParseUser)paramString;
}
public <T extends ParseObject> ParseRelation<T> getRelation(String paramString)
{
synchronized (this.mutex)
{
Object localObject2 = this.estimatedData.get(paramString);
if ((localObject2 instanceof ParseRelation))
{
localObject2 = (ParseRelation)localObject2;
((ParseRelation)localObject2).ensureParentAndKey(this, paramString);
return (ParseRelation<T>)localObject2;
}
localObject2 = new ParseRelation(this, paramString);
this.estimatedData.put(paramString, localObject2);
return (ParseRelation<T>)localObject2;
}
}
State getState()
{
synchronized (this.mutex)
{
State localState = this.state;
return localState;
}
}
public String getString(String paramString)
{
synchronized (this.mutex)
{
checkGetAccess(paramString);
paramString = this.estimatedData.get(paramString);
if (!(paramString instanceof String)) {
return null;
}
paramString = (String)paramString;
return paramString;
}
}
public Date getUpdatedAt()
{
long l = getState().updatedAt();
if (l > 0L) {
return new Date(l);
}
return null;
}
Task<Void> handleDeleteEventuallyResultAsync()
{
synchronized (this.mutex)
{
this.isDeletingEventually -= 1;
handleDeleteResultAsync().onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
Parse.getEventuallyQueue().notifyTestHelper(6);
return paramAnonymousTask;
}
});
}
}
Task<Void> handleDeleteResultAsync()
{
Task localTask = Task.forResult(null);
synchronized (this.mutex)
{
this.isDeleted = true;
final OfflineStore localOfflineStore = Parse.getLocalDatastore();
??? = localTask;
if (localOfflineStore != null) {
??? = localTask.continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> arg1)
throws Exception
{
synchronized (ParseObject.this.mutex)
{
if (ParseObject.this.isDeleted)
{
localOfflineStore.unregisterObject(ParseObject.this);
localTask = localOfflineStore.deleteDataForObjectAsync(ParseObject.this);
return localTask;
}
Task localTask = localOfflineStore.updateDataForObjectAsync(ParseObject.this);
return localTask;
}
}
});
}
return (Task<Void>)???;
}
}
Task<Void> handleFetchResultAsync(final State paramState)
{
Task localTask2 = Task.forResult((Void)null);
final OfflineStore localOfflineStore = Parse.getLocalDatastore();
Task localTask1 = localTask2;
if (localOfflineStore != null) {
localTask1 = localTask2.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
return localOfflineStore.fetchLocallyAsync(ParseObject.this).makeVoid();
}
}).continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
Task<Void> localTask = paramAnonymousTask;
if ((paramAnonymousTask.getError() instanceof ParseException))
{
localTask = paramAnonymousTask;
if (((ParseException)paramAnonymousTask.getError()).getCode() == 120) {
localTask = null;
}
}
return localTask;
}
});
}
localTask1 = localTask1.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
synchronized (ParseObject.this.mutex)
{
if (paramState.isComplete())
{
paramAnonymousTask = paramState;
ParseObject.this.setState(paramAnonymousTask);
return null;
}
paramAnonymousTask = ParseObject.this.getState().newBuilder().apply(paramState).build();
}
}
});
paramState = localTask1;
if (localOfflineStore != null) {
paramState = localTask1.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
return localOfflineStore.updateDataForObjectAsync(ParseObject.this);
}
}).continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
Task<Void> localTask = paramAnonymousTask;
if ((paramAnonymousTask.getError() instanceof ParseException))
{
localTask = paramAnonymousTask;
if (((ParseException)paramAnonymousTask.getError()).getCode() == 120) {
localTask = null;
}
}
return localTask;
}
});
}
return paramState;
}
Task<Void> handleSaveEventuallyResultAsync(JSONObject paramJSONObject, ParseOperationSet paramParseOperationSet)
{
if (paramJSONObject != null) {}
for (final boolean bool = true;; bool = false) {
handleSaveResultAsync(paramJSONObject, paramParseOperationSet).onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
if (bool) {
Parse.getEventuallyQueue().notifyTestHelper(5);
}
return paramAnonymousTask;
}
});
}
}
Task<Void> handleSaveResultAsync(final State paramState, final ParseOperationSet paramParseOperationSet)
{
Task localTask = Task.forResult((Void)null);
if (paramState != null) {}
for (int i = 1;; i = 0) {
synchronized (this.mutex)
{
final Object localObject2 = this.operationSetQueue.listIterator(this.operationSetQueue.indexOf(paramParseOperationSet));
((ListIterator)localObject2).next();
((ListIterator)localObject2).remove();
if (i == 0)
{
((ParseOperationSet)((ListIterator)localObject2).next()).mergeFrom(paramParseOperationSet);
return localTask;
}
localObject2 = Parse.getLocalDatastore();
??? = localTask;
if (localObject2 != null) {
??? = localTask.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
return localObject2.fetchLocallyAsync(ParseObject.this).makeVoid();
}
});
}
paramParseOperationSet = ((Task)???).continueWith(new Continuation()
{
public Void then(Task<Void> paramAnonymousTask)
throws Exception
{
synchronized (ParseObject.this.mutex)
{
if (paramState.isComplete())
{
paramAnonymousTask = paramState;
ParseObject.this.setState(paramAnonymousTask);
return null;
}
paramAnonymousTask = ParseObject.this.getState().newBuilder().apply(paramParseOperationSet).apply(paramState).build();
}
}
});
paramState = paramParseOperationSet;
if (localObject2 != null) {
paramState = paramParseOperationSet.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
return localObject2.updateDataForObjectAsync(ParseObject.this);
}
});
}
paramState.onSuccess(new Continuation()
{
public Void then(Task<Void> paramAnonymousTask)
throws Exception
{
ParseObject.this.saveEvent.invoke(ParseObject.this, null);
return null;
}
});
}
}
}
Task<Void> handleSaveResultAsync(JSONObject paramJSONObject, ParseOperationSet paramParseOperationSet)
{
Object localObject1 = null;
if (paramJSONObject != null) {}
synchronized (this.mutex)
{
localObject1 = new KnownParseObjectDecoder(collectFetchedObjects());
localObject1 = ParseObjectCoder.get().decode(getState().newBuilder().clear(), paramJSONObject, (ParseDecoder)localObject1).isComplete(false).build();
return handleSaveResultAsync((State)localObject1, paramParseOperationSet);
}
}
public boolean has(String paramString)
{
return containsKey(paramString);
}
boolean hasChanges()
{
for (;;)
{
synchronized (this.mutex)
{
if (currentOperations().size() > 0)
{
bool = true;
return bool;
}
}
boolean bool = false;
}
}
boolean hasOutstandingOperations()
{
for (boolean bool = true;; bool = false) {
synchronized (this.mutex)
{
if (this.operationSetQueue.size() > 1) {
return bool;
}
}
}
}
public boolean hasSameId(ParseObject paramParseObject)
{
for (;;)
{
synchronized (this.mutex)
{
if ((getClassName() != null) && (getObjectId() != null) && (getClassName().equals(paramParseObject.getClassName())) && (getObjectId().equals(paramParseObject.getObjectId())))
{
bool = true;
return bool;
}
}
boolean bool = false;
}
}
public void increment(String paramString)
{
increment(paramString, Integer.valueOf(1));
}
public void increment(String paramString, Number paramNumber)
{
performOperation(paramString, new ParseIncrementOperation(paramNumber));
}
boolean isContainerObject(String paramString, Object paramObject)
{
return ((paramObject instanceof JSONObject)) || ((paramObject instanceof JSONArray)) || ((paramObject instanceof Map)) || ((paramObject instanceof List)) || ((paramObject instanceof ParseACL)) || ((paramObject instanceof ParseGeoPoint));
}
public boolean isDataAvailable()
{
synchronized (this.mutex)
{
boolean bool = this.state.isComplete();
return bool;
}
}
boolean isDataAvailable(String paramString)
{
for (;;)
{
synchronized (this.mutex)
{
if (!isDataAvailable())
{
if (!this.estimatedData.containsKey(paramString)) {
break label44;
}
break label39;
return bool;
}
}
label39:
boolean bool = true;
continue;
label44:
bool = false;
}
}
public boolean isDirty()
{
return isDirty(true);
}
public boolean isDirty(String paramString)
{
synchronized (this.mutex)
{
boolean bool = currentOperations().containsKey(paramString);
return bool;
}
}
boolean isDirty(boolean paramBoolean)
{
for (;;)
{
synchronized (this.mutex)
{
checkForChangesToMutableContainers();
if ((!this.isDeleted) && (getObjectId() != null) && (!hasChanges()))
{
if ((!paramBoolean) || (!hasDirtyChildren())) {
break label60;
}
break label55;
return paramBoolean;
}
}
label55:
paramBoolean = true;
continue;
label60:
paramBoolean = false;
}
}
boolean isKeyMutable(String paramString)
{
return true;
}
public Set<String> keySet()
{
synchronized (this.mutex)
{
Set localSet = Collections.unmodifiableSet(this.estimatedData.keySet());
return localSet;
}
}
/* Error */
void mergeFromObject(ParseObject paramParseObject)
{
// Byte code:
// 0: aload_0
// 1: getfield 233 com/parse/ParseObject:mutex Ljava/lang/Object;
// 4: astore_2
// 5: aload_2
// 6: monitorenter
// 7: aload_0
// 8: aload_1
// 9: if_acmpne +6 -> 15
// 12: aload_2
// 13: monitorexit
// 14: return
// 15: aload_0
// 16: aload_1
// 17: invokevirtual 608 com/parse/ParseObject:getState ()Lcom/parse/ParseObject$State;
// 20: invokevirtual 873 com/parse/ParseObject$State:newBuilder ()Lcom/parse/ParseObject$State$Init;
// 23: invokevirtual 322 com/parse/ParseObject$State$Init:build ()Lcom/parse/ParseObject$State;
// 26: iconst_0
// 27: invokespecial 1482 com/parse/ParseObject:setState (Lcom/parse/ParseObject$State;Z)V
// 30: aload_2
// 31: monitorexit
// 32: return
// 33: astore_1
// 34: aload_2
// 35: monitorexit
// 36: aload_1
// 37: athrow
// Local variable table:
// start length slot name signature
// 0 38 0 this ParseObject
// 0 38 1 paramParseObject ParseObject
// 4 31 2 localObject Object
// Exception table:
// from to target type
// 12 14 33 finally
// 15 32 33 finally
// 34 36 33 finally
}
State mergeFromServer(State paramState, JSONObject paramJSONObject, ParseDecoder paramParseDecoder, boolean paramBoolean)
{
for (;;)
{
ParseObject.State.Init localInit;
try
{
localInit = paramState.newBuilder();
if (paramBoolean) {
localInit.clear();
}
if (paramState.isComplete()) {
break label249;
}
if (!paramBoolean) {
break label121;
}
}
catch (JSONException paramState)
{
throw new RuntimeException(paramState);
}
localInit.isComplete(paramBoolean);
paramState = paramJSONObject.keys();
if (paramState.hasNext())
{
String str = (String)paramState.next();
if ((!str.equals("__type")) && (!str.equals("className"))) {
if (str.equals("objectId"))
{
localInit.objectId(paramJSONObject.getString(str));
continue;
label121:
paramBoolean = false;
}
else if (str.equals("createdAt"))
{
localInit.createdAt(ParseDateFormat.getInstance().parse(paramJSONObject.getString(str)));
}
else if (str.equals("updatedAt"))
{
localInit.updatedAt(ParseDateFormat.getInstance().parse(paramJSONObject.getString(str)));
}
else if (str.equals("ACL"))
{
localInit.put("ACL", ParseACL.createACLFromJSONObject(paramJSONObject.getJSONObject(str), paramParseDecoder));
}
else
{
localInit.put(str, paramParseDecoder.decode(paramJSONObject.get(str)));
}
}
}
else
{
paramState = localInit.build();
return paramState;
label249:
paramBoolean = true;
}
}
}
void mergeREST(State paramState, JSONObject paramJSONObject, ParseDecoder paramParseDecoder)
{
ArrayList localArrayList = new ArrayList();
Object localObject1;
int i;
ParseOperationSet localParseOperationSet1;
synchronized (this.mutex)
{
try
{
boolean bool = paramJSONObject.getBoolean("__complete");
this.isDeletingEventually = ParseJSONUtils.getInt(paramJSONObject, Arrays.asList(new String[] { "__isDeletingEventually", "isDeletingEventually" }));
JSONArray localJSONArray = paramJSONObject.getJSONArray("__operations");
ParseOperationSet localParseOperationSet2 = currentOperations();
this.operationSetQueue.clear();
localObject1 = null;
i = 0;
if (i < localJSONArray.length())
{
localParseOperationSet1 = ParseOperationSet.fromRest(localJSONArray.getJSONObject(i), paramParseDecoder);
if (localParseOperationSet1.isSaveEventually())
{
Object localObject2 = localObject1;
if (localObject1 != null)
{
this.operationSetQueue.add(localObject1);
localObject2 = null;
}
localArrayList.add(localParseOperationSet1);
this.operationSetQueue.add(localParseOperationSet1);
localObject1 = localObject2;
break label370;
}
if (localObject1 == null) {
break label379;
}
localParseOperationSet1.mergeFrom((ParseOperationSet)localObject1);
break label379;
}
if (localObject1 != null) {
this.operationSetQueue.add(localObject1);
}
currentOperations().mergeFrom(localParseOperationSet2);
int j = 0;
if (paramState.updatedAt() < 0L) {
i = 1;
}
for (;;)
{
if (i != 0) {
setState(mergeFromServer(paramState, ParseJSONUtils.create(paramJSONObject, Arrays.asList(new String[] { "__complete", "__isDeletingEventually", "isDeletingEventually", "__operations" })), paramParseDecoder, bool));
}
paramState = localArrayList.iterator();
while (paramState.hasNext()) {
enqueueSaveEventuallyOperationAsync((ParseOperationSet)paramState.next());
}
i = j;
if (paramJSONObject.has("updatedAt"))
{
localObject1 = ParseDateFormat.getInstance().parse(paramJSONObject.getString("updatedAt"));
int k = new Date(paramState.updatedAt()).compareTo((Date)localObject1);
i = j;
if (k < 0) {
i = 1;
}
}
}
paramState = finally;
}
catch (JSONException paramState)
{
throw new RuntimeException(paramState);
}
}
return;
for (;;)
{
label370:
i += 1;
break;
label379:
localObject1 = localParseOperationSet1;
}
}
boolean needsDefaultACL()
{
return true;
}
ParseObject.State.Init<?> newStateBuilder(String paramString)
{
return new ParseObject.State.Builder(paramString);
}
void performOperation(String paramString, ParseFieldOperation paramParseFieldOperation)
{
synchronized (this.mutex)
{
Object localObject2 = paramParseFieldOperation.apply(this.estimatedData.get(paramString), paramString);
if (localObject2 != null)
{
this.estimatedData.put(paramString, localObject2);
paramParseFieldOperation = paramParseFieldOperation.mergeWithPrevious((ParseFieldOperation)currentOperations().get(paramString));
currentOperations().put(paramString, paramParseFieldOperation);
checkpointMutableContainer(paramString, localObject2);
return;
}
this.estimatedData.remove(paramString);
}
}
void performPut(String paramString, Object paramObject)
{
if (paramString == null) {
throw new IllegalArgumentException("key may not be null.");
}
if (paramObject == null) {
throw new IllegalArgumentException("value may not be null.");
}
if (!ParseEncoder.isValidType(paramObject)) {
throw new IllegalArgumentException("invalid type for value: " + paramObject.getClass().toString());
}
performOperation(paramString, new ParseSetOperation(paramObject));
}
void performRemove(String paramString)
{
synchronized (this.mutex)
{
if (get(paramString) != null) {
performOperation(paramString, ParseDeleteOperation.getInstance());
}
return;
}
}
public void pin()
throws ParseException
{
ParseTaskUtils.wait(pinInBackground());
}
public void pin(String paramString)
throws ParseException
{
ParseTaskUtils.wait(pinInBackground(paramString));
}
public Task<Void> pinInBackground()
{
return pinAllInBackground("_default", Arrays.asList(new ParseObject[] { this }));
}
public Task<Void> pinInBackground(String paramString)
{
return pinAllInBackground(paramString, Collections.singletonList(this));
}
Task<Void> pinInBackground(String paramString, boolean paramBoolean)
{
return pinAllInBackground(paramString, Collections.singletonList(this), paramBoolean);
}
public void pinInBackground(SaveCallback paramSaveCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(pinInBackground(), paramSaveCallback);
}
public void pinInBackground(String paramString, SaveCallback paramSaveCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(pinInBackground(paramString), paramSaveCallback);
}
public void put(String paramString, Object paramObject)
{
checkKeyIsMutable(paramString);
performPut(paramString, paramObject);
}
@Deprecated
public final void refresh()
throws ParseException
{
fetch();
}
@Deprecated
public final void refreshInBackground(RefreshCallback paramRefreshCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(fetchInBackground(), paramRefreshCallback);
}
void registerSaveListener(GetCallback<ParseObject> paramGetCallback)
{
synchronized (this.mutex)
{
this.saveEvent.subscribe(paramGetCallback);
return;
}
}
public void remove(String paramString)
{
checkKeyIsMutable(paramString);
performRemove(paramString);
}
public void removeAll(String paramString, Collection<?> paramCollection)
{
checkKeyIsMutable(paramString);
performOperation(paramString, new ParseRemoveOperation(paramCollection));
}
public void revert()
{
synchronized (this.mutex)
{
if (isDirty())
{
currentOperations().clear();
rebuildEstimatedData();
checkpointAllMutableContainers();
}
return;
}
}
public void revert(String paramString)
{
synchronized (this.mutex)
{
if (isDirty(paramString))
{
currentOperations().remove(paramString);
rebuildEstimatedData();
checkpointAllMutableContainers();
}
return;
}
}
public final void save()
throws ParseException
{
ParseTaskUtils.wait(saveInBackground());
}
Task<JSONObject> saveAsync(ParseOperationSet paramParseOperationSet, String paramString)
throws ParseException
{
return currentSaveEventuallyCommand(paramParseOperationSet, PointerEncoder.get(), paramString).executeAsync();
}
Task<Void> saveAsync(final String paramString)
{
this.taskQueue.enqueue(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymousTask)
throws Exception
{
return ParseObject.this.saveAsync(paramString, paramAnonymousTask);
}
});
}
Task<Void> saveAsync(final String paramString, Task<Void> paramTask)
{
if (!isDirty()) {
return Task.forResult(null);
}
final ParseOperationSet localParseOperationSet;
synchronized (this.mutex)
{
updateBeforeSave();
validateSave();
localParseOperationSet = startSave();
}
synchronized (this.mutex)
{
Task localTask = deepSaveAsync(this.estimatedData, paramString);
localTask.onSuccessTask(TaskQueue.waitFor(paramTask)).onSuccessTask(new Continuation()
{
public Task<ParseObject.State> then(Task<Void> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = new KnownParseObjectDecoder(ParseObject.this.collectFetchedObjects());
return ParseObject.access$800().saveAsync(ParseObject.this.getState(), localParseOperationSet, paramString, paramAnonymousTask);
}
}).continueWithTask(new Continuation()
{
public Task<Void> then(final Task<ParseObject.State> paramAnonymousTask)
throws Exception
{
ParseObject.State localState = (ParseObject.State)paramAnonymousTask.getResult();
ParseObject.this.handleSaveResultAsync(localState, localParseOperationSet).continueWithTask(new Continuation()
{
public Task<Void> then(Task<Void> paramAnonymous2Task)
throws Exception
{
if ((paramAnonymous2Task.isFaulted()) || (paramAnonymous2Task.isCancelled())) {
return paramAnonymous2Task;
}
return paramAnonymousTask.makeVoid();
}
});
}
});
paramString = finally;
throw paramString;
}
}
public final Task<Void> saveEventually()
{
if (!isDirty())
{
Parse.getEventuallyQueue().fakeObjectUpdate();
return Task.forResult(null);
}
synchronized (this.mutex)
{
updateBeforeSave();
}
final ParseOperationSet localParseOperationSet;
Object localObject4;
try
{
validateSaveEventually();
ArrayList localArrayList = new ArrayList();
collectDirtyChildren(this.estimatedData, localArrayList, null);
Object localObject1 = null;
if (getObjectId() == null) {
localObject1 = getOrCreateLocalId();
}
localParseOperationSet = startSave();
localParseOperationSet.setIsSaveEventually(true);
localObject4 = ParseUser.getCurrentSessionToken();
try
{
localObject4 = currentSaveEventuallyCommand(localParseOperationSet, PointerOrLocalIdEncoder.get(), (String)localObject4);
((ParseRESTCommand)localObject4).setLocalId((String)localObject1);
((ParseRESTCommand)localObject4).setOperationSetUUID(localParseOperationSet.getUUID());
((ParseRESTCommand)localObject4).retainLocalIds();
localObject1 = localArrayList.iterator();
while (((Iterator)localObject1).hasNext()) {
((ParseObject)((Iterator)localObject1).next()).saveEventually();
}
localObject2 = finally;
}
catch (ParseException localParseException1)
{
throw new IllegalStateException("Unable to saveEventually.", localParseException1);
}
throw ((Throwable)localObject2);
}
catch (ParseException localParseException2)
{
localTask = Task.forError(localParseException2);
return localTask;
}
Task localTask = Parse.getEventuallyQueue().enqueueEventuallyAsync((ParseRESTCommand)localObject4, this);
enqueueSaveEventuallyOperationAsync(localParseOperationSet);
((ParseRESTCommand)localObject4).releaseLocalIds();
if (Parse.isLocalDatastoreEnabled()) {
return localTask.makeVoid();
}
localTask.onSuccessTask(new Continuation()
{
public Task<Void> then(Task<JSONObject> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (JSONObject)paramAnonymousTask.getResult();
return ParseObject.this.handleSaveEventuallyResultAsync(paramAnonymousTask, localParseOperationSet);
}
});
}
public final void saveEventually(SaveCallback paramSaveCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(saveEventually(), paramSaveCallback);
}
public final Task<Void> saveInBackground()
{
ParseUser.getCurrentUserAsync().onSuccessTask(new Continuation()
{
public Task<String> then(final Task<ParseUser> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (ParseUser)paramAnonymousTask.getResult();
if (paramAnonymousTask == null) {
return Task.forResult(null);
}
if (!paramAnonymousTask.isLazy()) {
return Task.forResult(paramAnonymousTask.getSessionToken());
}
if (!ParseObject.this.isDataAvailable("ACL")) {
return Task.forResult(null);
}
paramAnonymousTask = ParseObject.this.getACL(false);
if (paramAnonymousTask == null) {
return Task.forResult(null);
}
final ParseUser localParseUser = paramAnonymousTask.getUnresolvedUser();
if ((localParseUser == null) || (!localParseUser.isCurrentUser())) {
return Task.forResult(null);
}
localParseUser.saveAsync(null).onSuccess(new Continuation()
{
public String then(Task<Void> paramAnonymous2Task)
throws Exception
{
if (paramAnonymousTask.hasUnresolvedUser()) {
throw new IllegalStateException("ACL has an unresolved ParseUser. Save or sign up before attempting to serialize the ACL.");
}
return localParseUser.getSessionToken();
}
});
}
}).onSuccessTask(new Continuation()
{
public Task<Void> then(Task<String> paramAnonymousTask)
throws Exception
{
paramAnonymousTask = (String)paramAnonymousTask.getResult();
return ParseObject.this.saveAsync(paramAnonymousTask);
}
});
}
public final void saveInBackground(SaveCallback paramSaveCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(saveInBackground(), paramSaveCallback);
}
public void setACL(ParseACL paramParseACL)
{
put("ACL", paramParseACL);
}
void setDefaultValues()
{
if ((needsDefaultACL()) && (ParseACL.getDefaultACL() != null)) {
setACL(ParseACL.getDefaultACL());
}
}
public void setObjectId(String paramString)
{
synchronized (this.mutex)
{
String str = this.state.objectId();
if (ParseTextUtils.equals(str, paramString)) {
return;
}
this.state = this.state.newBuilder().objectId(paramString).build();
notifyObjectIdChanged(str, paramString);
return;
}
}
void setState(State paramState)
{
synchronized (this.mutex)
{
setState(paramState, true);
return;
}
}
ParseOperationSet startSave()
{
synchronized (this.mutex)
{
ParseOperationSet localParseOperationSet = currentOperations();
this.operationSetQueue.addLast(new ParseOperationSet());
return localParseOperationSet;
}
}
<T extends State> JSONObject toJSONObjectForSaving(T paramT, ParseOperationSet paramParseOperationSet, ParseEncoder paramParseEncoder)
{
JSONObject localJSONObject = new JSONObject();
try
{
Iterator localIterator = paramParseOperationSet.keySet().iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
localJSONObject.put(str, paramParseEncoder.encode((ParseFieldOperation)paramParseOperationSet.get(str)));
}
if (paramT.objectId() == null) {
break label97;
}
}
catch (JSONException paramT)
{
throw new RuntimeException("could not serialize object to JSON");
}
localJSONObject.put("objectId", paramT.objectId());
label97:
return localJSONObject;
}
JSONObject toRest(ParseEncoder paramParseEncoder)
{
synchronized (this.mutex)
{
State localState = getState();
int j = this.operationSetQueue.size();
ArrayList localArrayList = new ArrayList(j);
int i = 0;
while (i < j)
{
localArrayList.add(new ParseOperationSet((ParseOperationSet)this.operationSetQueue.get(i)));
i += 1;
}
return toRest(localState, localArrayList, paramParseEncoder);
}
}
JSONObject toRest(State paramState, List<ParseOperationSet> paramList, ParseEncoder paramParseEncoder)
{
checkForChangesToMutableContainers();
JSONObject localJSONObject = new JSONObject();
try
{
localJSONObject.put("className", paramState.className());
if (paramState.objectId() != null) {
localJSONObject.put("objectId", paramState.objectId());
}
if (paramState.createdAt() > 0L) {
localJSONObject.put("createdAt", ParseDateFormat.getInstance().format(new Date(paramState.createdAt())));
}
if (paramState.updatedAt() > 0L) {
localJSONObject.put("updatedAt", ParseDateFormat.getInstance().format(new Date(paramState.updatedAt())));
}
Iterator localIterator = paramState.keySet().iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
localJSONObject.put(str, paramParseEncoder.encode(paramState.get(str)));
}
localJSONObject.put("__complete", paramState.isComplete());
}
catch (JSONException paramState)
{
throw new RuntimeException("could not serialize object to JSON");
}
localJSONObject.put("__isDeletingEventually", this.isDeletingEventually);
paramState = new JSONArray();
paramList = paramList.iterator();
while (paramList.hasNext()) {
paramState.put(((ParseOperationSet)paramList.next()).toRest(paramParseEncoder));
}
localJSONObject.put("__operations", paramState);
return localJSONObject;
}
public void unpin()
throws ParseException
{
ParseTaskUtils.wait(unpinInBackground());
}
public void unpin(String paramString)
throws ParseException
{
ParseTaskUtils.wait(unpinInBackground(paramString));
}
public Task<Void> unpinInBackground()
{
return unpinAllInBackground("_default", Arrays.asList(new ParseObject[] { this }));
}
public Task<Void> unpinInBackground(String paramString)
{
return unpinAllInBackground(paramString, Arrays.asList(new ParseObject[] { this }));
}
public void unpinInBackground(DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(unpinInBackground(), paramDeleteCallback);
}
public void unpinInBackground(String paramString, DeleteCallback paramDeleteCallback)
{
ParseTaskUtils.callbackOnMainThreadAsync(unpinInBackground(paramString), paramDeleteCallback);
}
void unregisterSaveListener(GetCallback<ParseObject> paramGetCallback)
{
synchronized (this.mutex)
{
this.saveEvent.unsubscribe(paramGetCallback);
return;
}
}
void updateBeforeSave() {}
void validateDelete() {}
void validateSave() {}
void validateSaveEventually()
throws ParseException
{}
static class State
{
private final String className;
private final long createdAt;
private final boolean isComplete;
private final String objectId;
private final Map<String, Object> serverData;
private final long updatedAt;
State(Init<?> paramInit)
{
this.className = paramInit.className;
this.objectId = paramInit.objectId;
this.createdAt = paramInit.createdAt;
if (paramInit.updatedAt > 0L) {}
for (long l = paramInit.updatedAt;; l = this.createdAt)
{
this.updatedAt = l;
this.serverData = Collections.unmodifiableMap(new HashMap(paramInit.serverData));
this.isComplete = paramInit.isComplete;
return;
}
}
public static Init<?> newBuilder(String paramString)
{
if ("_User".equals(paramString)) {
return new ParseUser.State.Builder();
}
return new Builder(paramString);
}
public String className()
{
return this.className;
}
public long createdAt()
{
return this.createdAt;
}
public Object get(String paramString)
{
return this.serverData.get(paramString);
}
public boolean isComplete()
{
return this.isComplete;
}
public Set<String> keySet()
{
return this.serverData.keySet();
}
public <T extends Init<?>> T newBuilder()
{
return new Builder(this);
}
public String objectId()
{
return this.objectId;
}
public String toString()
{
return String.format(Locale.US, "%s@%s[className=%s, objectId=%s, createdAt=%d, updatedAt=%d, isComplete=%s, serverData=%s]", new Object[] { getClass().getName(), Integer.toHexString(hashCode()), this.className, this.objectId, Long.valueOf(this.createdAt), Long.valueOf(this.updatedAt), Boolean.valueOf(this.isComplete), this.serverData });
}
public long updatedAt()
{
return this.updatedAt;
}
static class Builder
extends ParseObject.State.Init<Builder>
{
public Builder(ParseObject.State paramState)
{
super();
}
public Builder(String paramString)
{
super();
}
public ParseObject.State build()
{
return new ParseObject.State(this);
}
Builder self()
{
return this;
}
}
static abstract class Init<T extends Init>
{
private final String className;
private long createdAt = -1L;
private boolean isComplete;
private String objectId;
Map<String, Object> serverData = new HashMap();
private long updatedAt = -1L;
Init(ParseObject.State paramState)
{
this.className = paramState.className();
this.objectId = paramState.objectId();
this.createdAt = paramState.createdAt();
this.updatedAt = paramState.updatedAt();
Iterator localIterator = paramState.keySet().iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
this.serverData.put(str, paramState.get(str));
}
this.isComplete = paramState.isComplete();
}
public Init(String paramString)
{
this.className = paramString;
}
public T apply(ParseObject.State paramState)
{
if (paramState.objectId() != null) {
objectId(paramState.objectId());
}
if (paramState.createdAt() > 0L) {
createdAt(paramState.createdAt());
}
if (paramState.updatedAt() > 0L) {
updatedAt(paramState.updatedAt());
}
if ((this.isComplete) || (paramState.isComplete())) {}
for (boolean bool = true;; bool = false)
{
isComplete(bool);
Iterator localIterator = paramState.keySet().iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
put(str, paramState.get(str));
}
}
return self();
}
public T apply(ParseOperationSet paramParseOperationSet)
{
Iterator localIterator = paramParseOperationSet.keySet().iterator();
while (localIterator.hasNext())
{
String str = (String)localIterator.next();
Object localObject = ((ParseFieldOperation)paramParseOperationSet.get(str)).apply(this.serverData.get(str), str);
if (localObject != null) {
put(str, localObject);
} else {
remove(str);
}
}
return self();
}
abstract <S extends ParseObject.State> S build();
public T clear()
{
this.objectId = null;
this.createdAt = -1L;
this.updatedAt = -1L;
this.isComplete = false;
this.serverData.clear();
return self();
}
public T createdAt(long paramLong)
{
this.createdAt = paramLong;
return self();
}
public T createdAt(Date paramDate)
{
this.createdAt = paramDate.getTime();
return self();
}
public T isComplete(boolean paramBoolean)
{
this.isComplete = paramBoolean;
return self();
}
public T objectId(String paramString)
{
this.objectId = paramString;
return self();
}
public T put(String paramString, Object paramObject)
{
this.serverData.put(paramString, paramObject);
return self();
}
public T remove(String paramString)
{
this.serverData.remove(paramString);
return self();
}
abstract T self();
public T updatedAt(long paramLong)
{
this.updatedAt = paramLong;
return self();
}
public T updatedAt(Date paramDate)
{
this.updatedAt = paramDate.getTime();
return self();
}
}
}
}
/* Location: /Users/subdiox/Downloads/dex2jar-2.0/net.wargaming.wot.blitz-dex2jar.jar!/com/parse/ParseObject.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"subdiox@gmail.com"
] | subdiox@gmail.com |
6652d444daf148ee9fc9b3dfd67b7ad205ca39c5 | 26bf1d58122345933fb43784a5aaaa3a7b131001 | /src/main/java/com/cognizant/spring/controller/CourseController.java | 733c1afdaca431310e1805b0dcda96f67dc96da8 | [] | no_license | SamundarSingh/CourseCatalogingTool | c6fc1c494ff33354577d5a0a39311b1a99655c4d | 1c9eb0044bc364a4da3eb77b505e789782b93805 | refs/heads/master | 2022-12-31T16:28:14.286130 | 2020-10-24T20:06:08 | 2020-10-24T20:06:08 | 304,332,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,071 | java | package com.cognizant.spring.controller;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cognizant.spring.entity.Course;
import com.cognizant.spring.services.CourseService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@Controller
public class CourseController {
@Autowired
private CourseService courseService;
private final String courseStatus = "Active";
private List<Course> courseList = new ArrayList<Course>();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = null;
@RequestMapping("/home")
public String home() {
return "home/home";
}
@RequestMapping("/basicSearch")
@ResponseBody
public String findAllCourseUsingbasicSearch(@ModelAttribute("course") Course course) {
System.out.println("course: " + course);
String courseName = course.getCourseName() == null ? "" : course.getCourseName();
String courseSkillFamily = course.getCourseSkillFamily() == null ? "" : course.getCourseSkillFamily();
String courseProficiency = course.getCourseProficiency() == null ? "" : course.getCourseProficiency();
if (courseName != "" && courseSkillFamily != "" && courseProficiency != "") {
System.out.println("Three property are not null");
courseList = courseService.findCourseByCourseNameSkillProficiency(courseName, courseSkillFamily,
courseProficiency, courseStatus);
} else if (courseName != "" && courseSkillFamily != "") {
System.out.println("courseName and skillfamily not null");
courseList = courseService.findCourseByCourseNameSkill(courseName, courseSkillFamily, courseStatus);
} else if (courseSkillFamily != "" && courseProficiency != "") {
System.out.println("skill and proficiency not null");
courseList = courseService.findCourseBySkillProficiency(courseSkillFamily, courseProficiency, courseStatus);
} else if (courseProficiency != "" && courseName != "") {
System.out.println("proficiency and coursename not null");
courseList = courseService.findCourseByCourseNameProficiency(courseName, courseProficiency, courseStatus);
} else if (courseName != "") {
System.out.println("coursename is not null");
courseList = courseService.findCourseByCourseName(courseName, courseStatus);
} else if (courseSkillFamily != "") {
System.out.println("skill is not null");
courseList = courseService.findCourseBySkill(courseSkillFamily, courseStatus);
} else if (courseProficiency != "") {
System.out.println("proficiency not null");
courseList = courseService.findCourseByProficiency(courseProficiency, courseStatus);
}
Collections.sort(courseList);
json = gson.toJson(courseList);
System.out.println(json);
return json;
}
@RequestMapping("/advanceSearch")
@ResponseBody
public String findAllCourseUsingAdvanceSearch(@ModelAttribute("course") Course course) {
System.out.println("Course: " + course);
String courseCode = course.getCourseCode() == null ? "" : course.getCourseCode();
String courseDescription = course.getCourseDescription() == null ? "" : course.getCourseDescription();
String courseLicence = course.getCourseLicence() == null ? "" : course.getCourseLicence();
String courseActivityType = course.getCourseActivityType() == null ? "" : course.getCourseActivityType();
if (courseCode != "" && courseDescription != "" && courseLicence != "" && courseActivityType != "") {
System.out.println("Four property are not null");
courseList = courseService.findCourseByCodeDescriptionLicenceActivity(courseCode, courseDescription,
courseLicence, courseActivityType, courseStatus);
} else if (courseCode != "" && courseDescription != "" && courseLicence != "") {
System.out.println("courseName, courseDescription, courseLicence not null");
courseList = courseService.findCourseByCodeDescriptionLicence(courseCode, courseDescription, courseLicence,
courseStatus);
} else if (courseDescription != "" && courseLicence != "" && courseActivityType != "") {
System.out.println("courseDescription, courseLicence, courseActivityTypeString not null");
courseList = courseService.findCourseByDescriptionLicenceActivity(courseDescription, courseLicence,
courseActivityType, courseStatus);
} else if (courseCode != "" && courseLicence != "" && courseActivityType != "") {
System.out.println("courseCode, courseLicence, courseActivityTypeString not null");
courseList = courseService.findCourseByCodeLicenceActivity(courseCode, courseLicence, courseActivityType,
courseStatus);
} else if (courseCode != "" && courseDescription != "") {
System.out.println("courseCode, courseDescription not null");
courseList = courseService.findCourseByCodeDescription(courseCode, courseDescription, courseStatus);
} else if (courseCode != "" && courseLicence != "") {
System.out.println("courseLicence, courseLicence not null");
courseList = courseService.findCourseByCodeLicence(courseCode, courseLicence, courseStatus);
} else if (courseDescription != "" && courseLicence != "") {
System.out.println("courseDescription, courseLicence not null");
courseList = courseService.findCourseByDescriptionLicence(courseDescription, courseLicence, courseStatus);
} else if (courseDescription != "" && courseActivityType != "") {
System.out.println("courseActivityType, courseDescription not null");
courseList = courseService.findCourseByDescriptionActivity(courseDescription, courseActivityType,
courseStatus);
} else if (courseLicence != "" && courseActivityType != "") {
System.out.println("courseLicence, courseActivityTypeString not null");
courseList = courseService.findCourseByLicenceActivity(courseLicence, courseActivityType, courseStatus);
} else if (courseCode != "" && courseActivityType != "") {
System.out.println("courseCode, courseActivityTypeString not null");
courseList = courseService.findCourseByCodeActivity(courseCode, courseActivityType, courseStatus);
} else if (courseCode != "") {
System.out.println("courseCode not null");
courseList = courseService.findCourseByCode(courseCode, courseStatus);
} else if (courseDescription != "") {
System.out.println("courseDescription not null");
courseList = courseService.findCourseByDescription(courseDescription, courseStatus);
} else if (courseLicence != "") {
System.out.println("courseLicence not null");
courseList = courseService.findCourseByLicence(courseLicence, courseStatus);
} else if (courseActivityType != "") {
System.out.println("courseActivityTypeString not null");
courseList = courseService.findCourseByActivity(courseActivityType, courseStatus);
}
Collections.sort(courseList);
json = gson.toJson(courseList);
System.out.println(json);
return json;
}
}
| [
"samundarsingh@Samundars-MacBook-Pro.local"
] | samundarsingh@Samundars-MacBook-Pro.local |
134dca9167243ff7f5e0d62ebf67e36d7c2388db | 611fd8d347fa29cb5fea8ecb67ce4350bf5a996f | /Lab6/src/funcionario/Funcao.java | 7bb9b31ef93e189b5b5b8c34db5c6f5cc02dfb5e | [] | no_license | danilodox/Laboratorio-de-Programacao | 07d35c0ed9bffe846a3738b5b9ef616840f267bc | 584a53f4b698c6f4aadd729c90adc30053acd30c | refs/heads/master | 2021-01-22T18:42:20.074596 | 2018-06-12T21:15:44 | 2018-06-12T21:15:44 | 102,413,271 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 51 | java | package funcionario;
public interface Funcao {
}
| [
"danilomedeiros.dox@gmail.com"
] | danilomedeiros.dox@gmail.com |
d41c4afbe20460807836a5579c317a5ea77cdf3d | 23e33888ec1b4aa19cca8ffc5f858e543638ca35 | /components/auth/org.wso2.carbon.auth.scope.registration.rest.api/src/test/java/org/wso2/carbon/auth/scope/registration/rest/api/ScopeTestObjectCreator.java | 0afe63eadf34d4fa57b1841c504388eb9788831f | [
"Apache-2.0"
] | permissive | isurulucky/carbon-auth | 9ece9076c94536dc233d06054abf05bb3acb2e55 | 9c98255c4010d03b3da4331cb0fbf3b1039e44e7 | refs/heads/master | 2021-05-09T06:42:42.402505 | 2018-01-24T05:24:28 | 2018-01-24T05:24:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,673 | java | /*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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.wso2.carbon.auth.scope.registration.rest.api;
import org.mockito.Mockito;
import org.wso2.carbon.auth.scope.registration.impl.ScopeManagerImpl;
import org.wso2.carbon.auth.scope.registration.rest.api.dto.ScopeDTO;
import org.wso2.carbon.auth.scope.registration.rest.api.impl.ScopesApiServiceImpl;
import org.wso2.msf4j.Request;
import java.util.ArrayList;
/**
* Utility class used for generating test objects
*/
public class ScopeTestObjectCreator {
public static String SCOPE_NAME_1 = "scope1";
public static String SCOPE_NAME_2 = "scope2";
public static String SCOPE_NAME_3 = "scope3";
/**
* Creates a mocked Request object.
*
* @return mocked Request object
*/
public static Request getNewMockedRequest() {
return Mockito.mock(Request.class);
}
/**
* Create a ScopesApiServiceImpl based on an in memory DAO
*
* @return a ScopesApiServiceImpl based on an in memory DAO
*/
public static ScopesApiServiceImpl getNewScopesApiServiceImpl() {
return new ScopesApiServiceImpl(new ScopeManagerImpl(new ScopeTestDAO()));
}
/**
* Create a ScopesApiServiceImpl based on an in erroneous memory DAO
*
* @return a ScopesApiServiceImpl based on an in erroneous memory DAO
*/
public static ScopesApiServiceImpl getNewErroneousScopesApiServiceImpl() {
return new ScopesApiServiceImpl(new ScopeManagerImpl(new ScopeTestExceptionDAO()));
}
/**
* Creates a scope DTO
*
* @return a ScopeDTO based on the name
*/
public static ScopeDTO createScopeDTO(String name) {
ScopeDTO scopeDTO = new ScopeDTO();
scopeDTO.setName(name);
scopeDTO.setDescription(name + "-description");
scopeDTO.setBindings(new ArrayList<String>() {
{
for (int i = 0; i < name.length(); i++) {
add("role" + i);
}
}
});
return scopeDTO;
}
}
| [
"malintha.prasan@gmail.com"
] | malintha.prasan@gmail.com |
b10828296023a0645c889b711df6022018fff816 | e94283089810516f048bd58590036c88588112cb | /src/S2019ScoreStudentsSolvingMathExpression.java | bb2edec56dbf0c195ce520161b3ae38ac9ae19fc | [] | no_license | camelcc/leetcode | e0839e6267ebda5eef57da065d4adaefecb4b557 | d982b9e71bc475a599df45d66cf2b78cf017594d | refs/heads/master | 2022-07-19T06:24:49.148849 | 2022-07-10T07:00:34 | 2022-07-10T07:00:34 | 135,386,923 | 5 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,318 | java | import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
// https://leetcode.com/problems/the-score-of-students-solving-math-expression/discuss/1486306/PythonJava-Explanation-with-pictures-DP
public class S2019ScoreStudentsSolvingMathExpression {
public int calculate(String s) {
int i = 0;
Stack<Integer> stack = new Stack<>();
char operator = '+';
int num = 0;
while (i < s.length()) {
char ch = s.charAt(i++);
if (ch >= '0' && ch <= '9') num = ch - '0';
if (i >= s.length() || ch == '+' || ch == '*') {
if (operator == '+') stack.push(num);
else if (operator == '*') stack.push(stack.pop() * num);
operator = ch;
num = 0;
}
}
return stack.stream().mapToInt(Integer::intValue).sum();
}
public int scoreOfStudents(String s, int[] answers) {
int n = (int)(s.length() / 2 + 1);
Set<Integer>[][] res = new Set[n][n];
for (int i = 0; i < n; ++i){
res[i][i] = new HashSet<>();
res[i][i].add(s.charAt(2 * i) - '0');
}
for (int dif = 1; dif < n; ++dif){
for (int start = 0; start < n - dif; ++start){
int end = start + dif;
res[start][end] = new HashSet<>();
for (int i = start * 2 + 1; i < end * 2; i += 2){
if (s.charAt(i) - '+' == 0){
for (int a : res[start][(int)(i / 2)]){
for (int b : res[(int)(i / 2 + 1)][end]){
if (a + b <= 1000) res[start][end].add(a + b);
}
}
} else {
for (int a : res[start][(int)(i / 2)]){
for (int b : res[(int)(i / 2 + 1)][end]){
if (a * b <= 1000) res[start][end].add(a * b);
}
}
}
}
}
}
int correct = calculate(s), ans = 0;
for (int a : answers){
if (a == correct) ans += 5;
else if (res[0][n - 1].contains(a)) ans += 2;
}
return ans;
}
}
| [
"camel.young@gmail.com"
] | camel.young@gmail.com |
51989192bc778350f8633b6abe8c0678d7895ed6 | 8a165f7833e819d3983f41045227db96f9a890db | /app/util/Chinese2UTF8.java | 2330f08cd6118853d11c6721b98fc75563b9eb14 | [] | no_license | mathlemon/select-trad-v1 | f8c2cf80785918a9a6608d6bfb9168876612d030 | 63801658052add9545f93fb7d9eba2904a33590f | refs/heads/master | 2020-05-31T06:02:51.546256 | 2014-10-26T06:08:31 | 2014-10-26T06:08:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,066 | java | package util;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Chinese2UTF8 {
public static void main(String[] args) {
String strIn = "愛";
String strMid;
String strResult;
try {
strMid = new String(strIn.toString().getBytes("utf-8"));
System.out.println(strMid);
strResult = URLEncoder.encode(strMid, "utf-8");
//爱 %E9%90%96%EF%BF%BD
//愛 %E9%8E%B0%EF%BF%BD
System.out.println(strResult);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static String tranToUTF8(String ins) {
String strMid;
String strResult;
try {
strMid = new String(ins.toString().getBytes("utf-8"));
// System.out.println(strMid);
strResult = URLEncoder.encode(strMid, "utf-8");
//爱 %E9%90%96%EF%BF%BD
//愛 %E9%8E%B0%EF%BF%BD
// System.out.println(strResult);
return strResult;
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "";
}
}
| [
"lemonreading@gmail.com"
] | lemonreading@gmail.com |
2d6032403d893af14fbe7e84ee21715a1ac27646 | 95cd192e6dc1ccc2bd736017f2c3f9de6cfa6199 | /src/test/java/com/automation/tests/practice/POJOP/StudentP.java | dfe1e610868283cbcbd4e7fb4c022c90463f2716 | [] | no_license | hacetinay/summer-2019-online-rest-assured-testing | bee314047901a94645da7d877d6b0752011b4692 | 8016051bae2a125d7053e9e27c65d96b9eb28f17 | refs/heads/master | 2022-06-03T13:30:58.955217 | 2020-02-27T01:40:11 | 2020-02-27T01:40:11 | 243,405,072 | 0 | 0 | null | 2022-05-20T21:26:28 | 2020-02-27T01:39:45 | Java | UTF-8 | Java | false | false | 4,084 | java | package com.automation.tests.practice.POJOP;
public class StudentP {
private String admissionNo;
private int batch;
private String birthDate;
private CompanyP companyP;
private ContactP contactP;
private String firstName;
private String gender;
private String joinDate;
private String lastName;
private String major;
private String password;
private String section;
private int studentId;
private String subject;
public StudentP() {
}
@Override
public String toString() {
return "StudentP{" +
"admissionNo='" + admissionNo + '\'' +
", batch=" + batch +
", birthDate='" + birthDate + '\'' +
", companyP=" + companyP +
", contactP=" + contactP +
", firstName='" + firstName + '\'' +
", gender='" + gender + '\'' +
", joinDate='" + joinDate + '\'' +
", lastName='" + lastName + '\'' +
", major='" + major + '\'' +
", password='" + password + '\'' +
", section='" + section + '\'' +
", studentId=" + studentId +
", subject='" + subject + '\'' +
'}';
}
public StudentP(String admissionNo, int batch, String birthDate, CompanyP companyP, ContactP contactP, String firstName, String gender, String joinDate, String lastName, String major, String password, String section, String subject) {
this.admissionNo = admissionNo;
this.batch = batch;
this.birthDate = birthDate;
this.companyP = companyP;
this.contactP = contactP;
this.firstName = firstName;
this.gender = gender;
this.joinDate = joinDate;
this.lastName = lastName;
this.major = major;
this.password = password;
this.section = section;
this.subject = subject;
}
public String getAdmissionNo() {
return admissionNo;
}
public void setAdmissionNo(String admissionNo) {
this.admissionNo = admissionNo;
}
public int getBatch() {
return batch;
}
public void setBatch(int batch) {
this.batch = batch;
}
public String getBirthDate() {
return birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public CompanyP getCompanyP() {
return companyP;
}
public void setCompanyP(CompanyP companyP) {
this.companyP = companyP;
}
public ContactP getContactP() {
return contactP;
}
public void setContactP(ContactP contactP) {
this.contactP = contactP;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getJoinDate() {
return joinDate;
}
public void setJoinDate(String joinDate) {
this.joinDate = joinDate;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
}
| [
"hacetinay@gmail.com"
] | hacetinay@gmail.com |
cb0aff612933ac4b630d8e57a0582fa55d68b210 | 0af335a75f0d545bd8be2d6b401b49850da7cde9 | /src/main/java/objectcalisthenics/examples/firstclassecollections/Main.java | 6d93d05430c08d28b243256d18d64414f9cf92c7 | [] | no_license | igorferreira/ObjectCalisthenics | cac424acc68bc444154462682370c32397714ceb | ad56e891dc65f8a242a48838eea4ad86e4a7357c | refs/heads/main | 2023-02-03T07:50:17.338897 | 2020-12-17T03:50:50 | 2020-12-17T03:50:50 | 321,894,213 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,599 | java | package objectcalisthenics.examples.firstclassecollections;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
BoardRowCollection boardRowCollection = new BoardRowCollection(new ArrayList<>());
boardRowCollection.add(new BoardRow("1"));
boardRowCollection.add(new BoardRow("2"));
boardRowCollection.add(new BoardRow("3"));
boardRowCollection.add(new BoardRow("4"));
boardRowCollection.add(new BoardRow("5"));
boardRowCollection.add(new BoardRow("6"));
boardRowCollection.add(new BoardRow("7"));
boardRowCollection.add(new BoardRow("8"));
BoardColumnCollection boardColumnCollection = new BoardColumnCollection(new ArrayList<>());
boardColumnCollection.add(new BoardColumn("1"));
boardColumnCollection.add(new BoardColumn("2"));
boardColumnCollection.add(new BoardColumn("3"));
boardColumnCollection.add(new BoardColumn("4"));
boardColumnCollection.add(new BoardColumn("5"));
boardColumnCollection.add(new BoardColumn("6"));
boardColumnCollection.add(new BoardColumn("7"));
boardColumnCollection.add(new BoardColumn("8"));
Board board = new Board(boardRowCollection,boardColumnCollection);
Foo foo = new Foo(board.getRows());
Buu buu = new Buu(foo.getRows());
BoardRow row5 = foo.find5thRow();
BoardRow row8 = buu.find8thRow();
System.out.println("print row5: \n" + row5 + "\n\n");
System.out.println("print row8: \n" + row8 + "\n\n");
}
}
| [
"igorferreirabr@gmail.com"
] | igorferreirabr@gmail.com |
8280f854c8e3cd7c2e14a6c61e2eedb2e95d64c8 | f8f67ef4bf0f50aa98f805e2adaabcab5a087ed0 | /pagseguro-api/src/br/com/uol/pagseguro/logs/Logger.java | 0aece18e59dd898a4d45193063e51c7bb6ba0a40 | [] | no_license | rnakasato/ghstore-parent | 0f02035feed828051ef50c66e882ee5d97b125e1 | ec25befa6cc157d18617f699bcfae90c3897bc16 | refs/heads/master | 2020-01-27T09:55:40.848243 | 2016-12-07T15:20:51 | 2016-12-07T15:20:51 | 66,993,816 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,371 | java | /*
************************************************************************
Copyright [2011] [PagSeguro Internet Ltda.]
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 br.com.uol.pagseguro.logs;
/**
*
* Interface Logger
*/
public interface Logger {
/**
* Logger Debug
*
* @param message
*/
void debug( String message );
/**
* Logger Info
*
* @param message
*/
void info( String message );
/**
* Logger Warn
*
* @param message
*/
void warn( String message );
/**
* Logger error
*
* @param message
*/
void error( String message );
/**
* Logger Warn
*
* @param message
* @param t
*/
void warn( String message, Throwable t );
/**
* Logger Error
*
* @param message
* @param t
*/
void error( String message, Throwable t );
}
| [
"rafaelnakasato@outlook.com"
] | rafaelnakasato@outlook.com |
912724a02c6ded957dc2235138b69599693f1cf3 | 77f371503df3a5fa774d44c4e2f55271035f5237 | /Colossus/src/com/codexperiments/colossus/utility/ResourceUtil.java | 0494a42bb0541bbd2c414c651e148e6cb8b958e5 | [] | no_license | fdavudzade1/colossus | c73b9abbbe7d86c2b399bc73adef4195317d403e | 7c4ff909a307b2e475ca4341cf53bc18bda7234c | refs/heads/master | 2021-01-25T03:48:05.157993 | 2011-02-21T23:33:36 | 2011-02-21T23:33:36 | 34,263,875 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,654 | java | package com.codexperiments.colossus.utility;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
public final class ResourceUtil
{
private Context mContext;
private TypedArray mCustomAttributes;
public ResourceUtil (Context pContext, AttributeSet pAttrSet, int[] pAttr, int pDefStyleAttr)
{
super();
mContext = pContext;
if (pAttrSet != null) {
mCustomAttributes = pContext.obtainStyledAttributes(pAttrSet, pAttr, pDefStyleAttr, 0);
}
}
public void close() {
mCustomAttributes.recycle();
}
/**
* Retrieves a resource Id stored in a custom attribute (see attr.xml files) if defined. In case
* it is not, returns the default resource Id specified.
*
* @param pCustomAttributeId Id of the custom attribute containing the searched resource.
* @param pDefaultResourceId Default Id to return (not a custom attribute Id but a resource Id)
* @return Resource Id defined in the specified custom attribute or pDefaultId if it is not.
*/
public int getResourceId (int pCustomAttributeId, int pDefaultResourceId)
{
if (mCustomAttributes != null) {
return mCustomAttributes.getResourceId(pCustomAttributeId, pDefaultResourceId);
} else {
return pDefaultResourceId;
}
}
/**
* Retrieves a string stored in a custom attribute (see attr.xml files) if defined. In case it
* is not, returns the default string specified.
*
* @param pCustomAttributeId Id of the custom attribute containing the searched string.
* @param pDefaultId Default Id to return (not a custom attribute Id but a resource Id)
* @return String defined in the specified custom attribute or pDefaultId if it is not.
*/
public String getString (int pCustomAttributeId, String pDefaultString)
{
if (mCustomAttributes != null) {
String lResult = mCustomAttributes.getString(pCustomAttributeId);
if (lResult != null) {
return lResult;
} else {
return pDefaultString;
}
} else {
return pDefaultString;
}
}
/**
* Retrieves a string stored in a custom attribute (see attr.xml files) if defined. In case it
* is not, returns the default string specified.
*
* @param pCustomAttributeId Id of the custom attribute containing the searched string.
* @param pDefaultId Default Id to return (not a custom attribute Id but a resource Id)
* @return String defined in the specified custom attribute or pDefaultId if it is not.
*/
public String getString (int pCustomAttributeId, int pDefaultStringId)
{
if (mCustomAttributes != null) {
String lResult = mCustomAttributes.getString(pCustomAttributeId);
if (lResult != null) {
return lResult;
} else {
return mContext.getString(pDefaultStringId);
}
} else {
return mContext.getString(pDefaultStringId);
}
}
/**
* Retrieves an integer stored in a custom attribute (see attr.xml files) if defined. In case it
* is not, returns the default integer specified.
*
* @param pCustomAttributeId Id of the custom attribute containing the searched integer.
* @param pDefaultId Default Id to return (not a custom attribute Id but a resource Id)
* @return String defined in the specified custom attribute or pDefaultId if it is not.
*/
public int getInteger (int pCustomAttributeId, int pDefaultInteger)
{
if (mCustomAttributes != null) {
return mCustomAttributes.getInt(pCustomAttributeId, pDefaultInteger);
} else {
return pDefaultInteger;
}
}
/**
* Retrieves a boolean stored in a custom attribute (see attr.xml files) if defined. In case it
* is not, returns the default boolean specified.
*
* @param pCustomAttributeId Id of the custom attribute containing the searched boolean.
* @param pDefaultId Default Id to return (not a custom attribute Id but a resource Id)
* @return String defined in the specified custom attribute or pDefaultId if it is not.
*/
public boolean getBoolean (int pCustomAttributeId, boolean pDefaultBoolean)
{
if (mCustomAttributes != null) {
return mCustomAttributes.getBoolean(pCustomAttributeId, pDefaultBoolean);
} else {
return pDefaultBoolean;
}
}
}
| [
"ratamovic@885c1ea8-ae91-26eb-9b7e-5ebc692c4f45"
] | ratamovic@885c1ea8-ae91-26eb-9b7e-5ebc692c4f45 |
395d84e328c4d7cb733eeea0c4f1e1e91aceaafb | 8a9e2c99883e39945451c35b62d81a2612c57ecb | /app/src/main/java/com/example/analysis/Open.java | 1569aba5c75215956403771be2ff76e5e517758e | [] | no_license | qianqianjie717/Analysis | 3edbceb96f9678f9c3f8a33ff9da60793de046d5 | da504ed94ac47e27bf6764ac469eb31f849e6f00 | refs/heads/master | 2023-01-03T00:19:13.585914 | 2020-11-01T03:27:57 | 2020-11-01T03:27:57 | 309,002,099 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 761 | java | package com.example.analysis;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Open extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(Open.this, Loading.class);
startActivity(intent);
}
});
}
}
| [
"2863288322@qq.com"
] | 2863288322@qq.com |
65818cc9a3cea2e46cec3dea6bd4d0906821c91c | df804edc612509cdf11aefb5b8ea2e44b8b37d0d | /src/main/java/org/khmeracademy/smg_btb/controller/subject/SubjectController.java | 3851720a95c68772c8df4322aa0c7e2c128b024d | [] | no_license | hengmengtang/SCHOOLMANAGEMENT_API | 186711d507cbcd4be53f525bed182ec46dbf7fcd | 62df15b5e16ac0bf8aa3e29ab0875c851ccca48e | refs/heads/master | 2020-04-06T06:54:12.500247 | 2016-09-01T02:09:25 | 2016-09-01T02:09:25 | 64,717,551 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,757 | java | package org.khmeracademy.smg_btb.controller.subject;
import java.util.ArrayList;
import org.khmeracademy.smg_btb.entity.form.add_mark.ParamForGetSubject;
import org.khmeracademy.smg_btb.entity.form.max_id.MaxId;
import org.khmeracademy.smg_btb.entity.student.Student;
import org.khmeracademy.smg_btb.entity.subject.Subject;
import org.khmeracademy.smg_btb.service.subject.SubjectService;
import org.khmeracademy.smg_btb.utils.Response;
import org.khmeracademy.smg_btb.utils.ResponseCode;
import org.khmeracademy.smg_btb.utils.ResponseList;
import org.khmeracademy.smg_btb.utils.ResponseRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/subject")
public class SubjectController {
@Autowired
SubjectService subjectService;
@RequestMapping(value="/find-all-subject",method=RequestMethod.GET)
public ResponseList<Subject> findAll(){
ResponseList<Subject> response=new ResponseList<>();
ArrayList<Subject> subjectList=subjectService.findAll();
if(subjectList.isEmpty()){
response.setCode(ResponseCode.RECORD_NOT_FOUND);
}
else{
response.setCode(ResponseCode.RECORD_FOUND);
}
response.setData(subjectList);
return response;
}
@RequestMapping(value="/add-subject",method=RequestMethod.POST)
public Response insertSubject(@RequestBody Subject subject){
Response response=new Response();
try{
if(subjectService.insert(subject))
response.setCode(ResponseCode.INSERT_SUCCESS);
else
response.setCode(ResponseCode.INSERT_FAIL);
}catch(Exception ex){
ex.printStackTrace();
}
return response;
}
@RequestMapping(value="/auto-subject-id",method=RequestMethod.GET)
public ResponseRecord<MaxId> selectMaxId(){
ResponseRecord<MaxId> response=new ResponseRecord<>();
MaxId maxId=subjectService.selectMax();
if(maxId==null)
response.setCode(ResponseCode.FAIL);
else
response.setCode(ResponseCode.SUCCESS);
response.setData(maxId);
return response;
}
@RequestMapping(value="/get-current-subject-in-course",method=RequestMethod.POST)
public ResponseList<Subject> getSubjectInCourse(@RequestBody ParamForGetSubject subject){
ResponseList<Subject> response=new ResponseList<>();
ArrayList<Subject> subjectList=subjectService.getSubjectInCourse(subject);
if(subjectList.isEmpty()){
response.setCode(ResponseCode.RECORD_NOT_FOUND);
}
else{
response.setCode(ResponseCode.RECORD_FOUND);
}
response.setData(subjectList);
return response;
}
@RequestMapping(value="/change-status/{subject_id}",method=RequestMethod.POST)
public Response changeStatus(@PathVariable("subject_id") String subject_id){
Response response=new Response();
try{
if(subjectService.changStatus(subject_id))
response.setCode(ResponseCode.UPDATE_SUCCESS);
else
response.setCode(ResponseCode.UPDATE_FAIL);
}catch(Exception ex){
ex.printStackTrace();
}
return response;
}
@RequestMapping(value="/find-subject-by-subjectname/{subject_name}",method=RequestMethod.GET)
public ResponseRecord<Subject> findSubjectBySubjectname(@PathVariable("subject_name") String subject_name){
ResponseRecord<Subject> response=new ResponseRecord<>();
Subject subject=subjectService.findSubjectBySubjectname(subject_name);
if(subject==null)
response.setCode(ResponseCode.FAIL);
else
response.setCode(ResponseCode.SUCCESS);
response.setData(subject);
return response;
}
} | [
"heng.mengtang@gmail.com"
] | heng.mengtang@gmail.com |
cc91189c35aa101ca2ca6b4768c98b76806e0cf3 | 16e616ba9929956254ed80cb10ce6028f238932b | /src/main/java/com/employee/service/exceptions/ErrorDetails.java | c4a036681ed26f69ba215708dd990d43c2394da6 | [] | no_license | sureshg1986/EmployeeService | 2ca675aaf596ac8ee4b111c8b78ce5fb49ff35c4 | 20dea135aedf4c600d3ff20d2c65fdca80e8c73c | refs/heads/master | 2020-03-26T20:52:55.712893 | 2018-08-20T02:09:05 | 2018-08-20T02:09:05 | 145,352,335 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,055 | java | package com.employee.service.exceptions;
import java.util.Date;
public class ErrorDetails {
private Date timestamp;
private String message;
private String details;
private String code;
public ErrorDetails(Date timestamp, String message, String details) {
this(timestamp, message, "", details);
}
public ErrorDetails(Date timestamp, String message, String code, String details) {
super();
this.code=code;
this.timestamp = timestamp;
this.message = message;
this.details = details;
}
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
} | [
"noreply@github.com"
] | sureshg1986.noreply@github.com |
f9dbc9fe65d4b7b89ea35479a4f59179c9c8ef8b | 781595c61505dee3f2115430acadb360e106ee9b | /src/main/java/xyz/meunier/wav2pzx/input/AudioSamplePulseListBuilder.java | 7387471df6766471272e06ad7b02a65554255cd9 | [
"BSD-2-Clause"
] | permissive | fmeunier/wav2pzx | 26dd57fb967967a43916a5cff66329f4b601f8c4 | 8941341e3b5cdf170a8eb64b775798eca476cebe | refs/heads/master | 2020-12-29T02:37:17.972574 | 2017-02-10T12:44:01 | 2017-02-10T12:44:01 | 52,424,911 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,412 | java | /*
* Copyright (c) 2017, Fredrick Meunier
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package xyz.meunier.wav2pzx.input;
import xyz.meunier.wav2pzx.input.triggers.Bistable;
import xyz.meunier.wav2pzx.pulselist.PulseList;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
/**
* The aim of this class is to take a series of samples from an external source
* and convert them into an array list of pulse durations in T states
*
* @author Fredrick Meunier
*/
final class AudioSamplePulseListBuilder {
private final double tStatesPerSample;
private final Bistable bistable;
private SamplePulseGenerator samplePulseGenerator;
/**
* Construct a new AudioSamplePulseListBuilder.
* @param sampleRate the sample rate of the source file, must be less than targetHz
* @param targetHz the sample rate to resample to
* @param trigger determines when the signal level of a sample should be 0 or 1
*/
AudioSamplePulseListBuilder(float sampleRate, float targetHz, Bistable trigger) {
// Assert sampleRate > 0
checkArgument(sampleRate > 0, "Sample rate must be greater than 0, sample rate: " + sampleRate);
// Assert targetHz >= sampleRate
// note that we expect targetHz to be in MHz and audio samples are not
// expected to be in this range for the foreseeable future
checkArgument(targetHz >= sampleRate, "Target Hz must be greater than or equal to sample rate, target Hz:" + targetHz + " sample rate: " + sampleRate);
tStatesPerSample = targetHz / sampleRate;
bistable = trigger;
samplePulseGenerator = new SamplePulseGenerator();
}
/**
* @return the number of tstates per sample
*/
double getTStatesPerSample() {
return tStatesPerSample;
}
/**
* @return whether this builder has completed and built the tape
*/
boolean isTapeComplete() {
return samplePulseGenerator.isTapeComplete();
}
/**
* Add a sample from the source to the PulseList under construction
* @param sample new unsigned byte sample value, range is expected to be 0 - 255
* @throws IllegalStateException if the tape is complete
* @throws IllegalArgumentException if the sample is out of range
*/
void addSample(int sample) {
// State error, tape is already complete so no more pulses
checkState(!samplePulseGenerator.isTapeComplete(), "Pulse length list has already been marked as complete");
checkArgument( sample >= 0 & sample <= 255, "Sample out of range, should be 0-255, value: " + sample);
int newLevel = bistable.getNewLevel(sample);
samplePulseGenerator.addSample(newLevel, tStatesPerSample);
}
/**
* Construct the new PulseList and mark the tape as being complete
* @return the PulseList
* @throws IllegalStateException if we haven't yet processed any samples from the tape
*/
public PulseList build() {
return samplePulseGenerator.build();
}
}
| [
"fredm@spamcop.net"
] | fredm@spamcop.net |
be20e2e7a121c88cd36673b35ee92b2248e1a8ae | 4c7a9dca94c0082edf80aa97eb2c33c919a91054 | /Strings.java | 65db75214343393bac2b6e2f7be9d932dc63a4bd | [] | no_license | vinayak-sk/HackerRank-30-DaysOfCode | 52b8283f080198f490fb581761613706b69e7fe2 | 665e01a030567a7a04b044f07cf12e48bf34d796 | refs/heads/master | 2020-04-06T06:56:32.479497 | 2016-08-21T20:58:23 | 2016-08-21T20:58:23 | 64,943,849 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,396 | java | /*
Task
Given a string, S, of length N that is indexed from 0 to N-1,
print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line.
Sample Input
2
Hacker
Rank
Sample Output
Hce akr
Rn ak
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Strings {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String[] stringArray = new String[20];
for(int i=0; i <= n; i++){
stringArray[i] = in.nextLine();
//System.out.println(stringArray[i]);
}
in.close();
String evenString, oddString, currentString = "";
for(int j=0; j<=n; j++){
currentString = stringArray[j];
evenString = "";
oddString = "";
for(int k=0; k<currentString.length(); k++){
if(k%2==0){
evenString = evenString + currentString.charAt(k);
}
else{
oddString = oddString + currentString.charAt(k);
}
}
if(j!=0)
System.out.println(evenString + " " + oddString);
}
}
} | [
"vinayak1592@gmail.com"
] | vinayak1592@gmail.com |
9ea29794d1a0e800a3a2fcfa613c6d171991310b | 792b3f3910d9358113cf9ac25bddeba144557658 | /app/src/main/java/SomePrivateClasses/Calculation.java | 4869e1e6bc3d6324f6b00acfe229de9c44a9ee0c | [] | no_license | ws752499660/Luck_Counter | 55857938d3edd6a16d5297a3e5149343ba4a06bf | 8684a3299d2b388ee1dc14881c68d24ce84fe893 | refs/heads/master | 2021-09-13T23:50:21.515379 | 2018-03-22T15:30:47 | 2018-03-22T15:30:47 | 126,023,802 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,112 | java | package SomePrivateClasses;
import java.lang.Math;
/**
* Created by wily on 2018/3/21.
*/
public class Calculation
{
double rarity;
double RP;
double nextRarity;
final double RP_To_nextRaity_Coefficient=2.1;
public Calculation(double rarity,double RP)
{
this.rarity=rarity;
this.RP=RP;
this.rarity=0;
}
public Calculation()
{
this.rarity=0;
this.RP=0;
this.nextRarity=0;
}
public double AlterRP(double rarity,double RPold)
{
double fix=0;
if(rarity>=0.5) //可认为这样的事件是可以增加人品的
{
fix = (Math.log10(rarity) - Math.log10(0.5)) * rarity;
}
if(rarity<0.5) //可以认为这样的事件是减少人品的
{
fix=(Math.log10(rarity)-Math.log10(0.5)) *(1-rarity);
}
RP=RP+fix;
return fix;
}
public double Calculate_nextRarity(Rarity OriginRarity)
{
nextRarity=Math.pow(RP_To_nextRaity_Coefficient,RP)*OriginRarity.Probability;
return nextRarity;
}
}
| [
"ws752499660@foxmail.com"
] | ws752499660@foxmail.com |
6dd6035e45599d047ab332a52b3b4d0ca4918ff8 | cf21afe30f0cd99eba22d0ec327310de8970d9bf | /src/main/java/net/thearchon/hq/app/checks/ProxyServerCheck.java | dd28dae9a5fb935411df0c4c7e745d63de86bfeb | [] | no_license | ColeBennett/archon-hq | 855ddf2c7ac48f2c9909fbffd56846baa27732a6 | df5e59a5c63107a45bf17dd00a74a92296687ca8 | refs/heads/master | 2023-07-27T04:56:38.555049 | 2021-09-10T18:38:40 | 2021-09-10T18:38:40 | 405,176,155 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,339 | java | package net.thearchon.hq.app.checks;
import net.thearchon.hq.Archon;
import net.thearchon.hq.app.AbstractCheck;
import net.thearchon.hq.app.OutboundInterval;
public class ProxyServerCheck extends AbstractCheck {
private final Archon archon;
public ProxyServerCheck(Archon archon, int interval) {
super(interval);
this.archon = archon;
}
@Override
public void check(OutboundInterval outbound) {
// BungeeHandler handler = archon.getHandler(ServerType.BUNGEE);
// Collection<BungeeClient> clients = handler.getClients();
// if (!clients.isEmpty()) {
// long curr = System.currentTimeMillis();
// for (BungeeClient proxy : clients) {
// if (proxy.isActive() && (curr - proxy.getLastUpdated()) <= 20000) {
// ProxyInfo info = new ProxyInfo(proxy.getId(), proxy.getIpAddress());
// info.setOnlineCount(proxy.getOnlineCount());
// info.setUptime(proxy.getUptime());
// info.setFreeMemory(proxy.getFreeMemory());
// info.setMaxMemory(proxy.getMaxMemory());
// info.setTotalMemory(proxy.getTotalMemory());
// outbound.queue(new PacketProxyInfoUpdate(info));
// }
// }
// }
}
}
| [
"cole7405bennett@gmail.com"
] | cole7405bennett@gmail.com |
cdf558f9980fee602c93c7d553014024e7c1ecfe | 809fcdc542c287400becd14e5973e574f47fcc8a | /src/main/java/processor/MongoDb.java | f1981d3eee10c4f3af19e2f199ab62202f5366f9 | [] | no_license | nguyenviettduy/scheduling | 6738edb63a3296c2dec76153b3d718956b84796a | b2ff0e41684c4562461eaae1648a30628b639e02 | refs/heads/master | 2022-11-12T09:57:39.373041 | 2020-05-03T14:47:27 | 2020-05-03T14:47:27 | 260,947,178 | 0 | 0 | null | 2020-07-01T19:14:11 | 2020-05-03T14:46:02 | Java | UTF-8 | Java | false | false | 114 | java | package processor;
public class MongoDb extends AbstractNoSql{
@Override
public void config() {
}
}
| [
"nguyenviettduy@gmail.com"
] | nguyenviettduy@gmail.com |
ab25d8d89bc6eb2c8615fe673f594929b7993fc4 | 5217d79af2ca6232edec96a2d8ffe371935e93df | /chorus/src/main/java/org/chorusbdd/chorus/executionlistener/ExecutionListenerSupport.java | 76d74e314e336b167e7e9e7496cc14373f2762a3 | [
"MIT"
] | permissive | deepakcdo/Chorus | f263c201a9220ef760826f8f55fe53e36b57491c | c22362a71db7afc22b75cbc9e443ae39018b0995 | refs/heads/master | 2021-01-17T06:06:25.342740 | 2014-07-09T20:41:00 | 2014-07-09T20:41:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,754 | java | /**
* Copyright (C) 2000-2013 The Software Conservancy and Original Authors.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Nothing in this notice shall be deemed to grant any rights to trademarks,
* copyrights, patents, trade secrets or any other intellectual property of the
* licensor or any contributor except as expressly stated herein. No patent
* license is granted separate from the Software, for code that you delete from
* the Software, or for combinations of the Software with other software or
* hardware.
*/
package org.chorusbdd.chorus.executionlistener;
import org.chorusbdd.chorus.results.ExecutionToken;
import org.chorusbdd.chorus.results.FeatureToken;
import org.chorusbdd.chorus.results.ScenarioToken;
import org.chorusbdd.chorus.results.StepToken;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* User: nick
* Date: 16/05/12
* Time: 22:03
* To change this template use File | Settings | File Templates.
*/
public class ExecutionListenerSupport {
private List<ExecutionListener> listeners = new ArrayList<ExecutionListener>();
//
// Execution event methods
//
public void addExecutionListener(ExecutionListener... listeners) {
this.listeners.addAll(Arrays.asList(listeners));
}
public boolean removeExecutionListener(ExecutionListener... listeners) {
return this.listeners.removeAll(Arrays.asList(listeners));
}
public void addExecutionListener(Collection<ExecutionListener> listeners) {
this.listeners.addAll(listeners);
}
public void removeExecutionListeners(List<ExecutionListener> listeners) {
this.listeners.removeAll(listeners);
}
/**
* Clear any existing listeners and add the listeners provided
*/
public void setExecutionListener(ExecutionListener... listener) {
listeners.clear();
listeners.addAll(Arrays.asList(listener));
}
public void notifyStartTests(ExecutionToken t) {
for (ExecutionListener listener : listeners) {
listener.testsStarted(t);
}
}
public void notifyStepStarted(ExecutionToken t, StepToken step) {
for (ExecutionListener listener : listeners) {
listener.stepStarted(t, step);
}
}
public void notifyStepCompleted(ExecutionToken t, StepToken step) {
for (ExecutionListener listener : listeners) {
listener.stepCompleted(t, step);
}
}
public void notifyFeatureStarted(ExecutionToken t, FeatureToken feature) {
for (ExecutionListener listener : listeners) {
listener.featureStarted(t, feature);
}
}
public void notifyFeatureCompleted(ExecutionToken t, FeatureToken feature) {
for (ExecutionListener listener : listeners) {
listener.featureCompleted(t, feature);
}
}
public void notifyScenarioStarted(ExecutionToken t, ScenarioToken scenario) {
for (ExecutionListener listener : listeners) {
listener.scenarioStarted(t, scenario);
}
}
public void notifyScenarioCompleted(ExecutionToken t, ScenarioToken scenario) {
for (ExecutionListener listener : listeners) {
listener.scenarioCompleted(t, scenario);
}
}
public void notifyTestsCompleted(ExecutionToken t, List<FeatureToken> features) {
for (ExecutionListener listener : listeners) {
listener.testsCompleted(t, features);
}
}
public List<ExecutionListener> getListeners() {
return new ArrayList<ExecutionListener>(listeners);
}
}
| [
"nick@objectdefinitions.com"
] | nick@objectdefinitions.com |
1408fb7e65d5146b68677d9c2aca03ae0d4480eb | 4359acb4ab5752695f8b1feaf067378898cf2360 | /app/src/main/java/com/example/admin/tcp_client_andoird/MainActivity.java | 4b99053a7e47be8e1eaf53564d1176559edab8e0 | [] | no_license | Agent2H/TCP_Client_Android | 625486172e08324188fc29b1c0d7c7f4ce1ee38a | e727c649aa0ca32b90b6253066d186a8a2070fa9 | refs/heads/master | 2020-05-13T18:33:58.001715 | 2019-04-14T14:17:13 | 2019-04-14T14:17:13 | 181,649,615 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,045 | java | package com.example.admin.tcp_client_andoird;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.ftdi.j2xx.D2xxManager;
import com.ftdi.j2xx.FT_Device;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
public class MainActivity extends AppCompatActivity {
/*Variables*/
private static final int ROVER_PORT = 4445;
private static final String HOST_NAME = "gpsfutureuse.ddns.net";
private Socket socket;
private boolean serverConnected = false;
private boolean serialConnected = false;
private static DataOutputStream out;
private TextView textViewLog;
private Button btnConnectServer,btnConnectSerial;
private static D2xxManager ftD2xx = null;
private FT_Device ftDev;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AnhXa();
SetDefaultText();
btnConnectServer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new connectServerTask().execute();
}
});
btnConnectSerial.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
connectSerial();
}
});
}
private void SetDefaultText() {
textViewLog.setText("Status Displayed Here");
}
private void AnhXa() {
textViewLog = findViewById(R.id.textLogger);
btnConnectServer = findViewById(R.id.btnConnectServer);
btnConnectSerial = findViewById(R.id.btnConnectSerial);
}
private void log(String msg) {
System.out.println(textViewLog.getText());
LogTask task = new LogTask(textViewLog,msg);
task.execute();
}
private void connectSerial()
{
try {
ftD2xx = D2xxManager.getInstance(this);
} catch (D2xxManager.D2xxException ex) {
log(ex.toString());
}
int devCount = ftD2xx.createDeviceInfoList(getBaseContext());
log("Device number : " + Integer.toString(devCount));
D2xxManager.FtDeviceInfoListNode[] deviceList = new D2xxManager.FtDeviceInfoListNode[devCount];
ftD2xx.getDeviceInfoList(devCount, deviceList);
if (devCount <= 0) {
return;
}
if (ftDev == null) {
ftDev = ftD2xx.openByIndex(getBaseContext(), 0);
log("Open serial port");
}
if (ftDev.isOpen()) {
ftDev.setBaudRate(9600);
ftDev.setBitMode((byte) 0, D2xxManager.FT_BITMODE_RESET);
ftDev.setDataCharacteristics(D2xxManager.FT_DATA_BITS_8, D2xxManager.FT_STOP_BITS_1, D2xxManager.FT_PARITY_NONE);
ftDev.setFlowControl(D2xxManager.FT_FLOW_NONE, (byte) 0x0b, (byte) 0x0d);
log("Set parameters");
serialConnected = true;
}
}
public class connectServerTask extends AsyncTask<Void,Void,Void>{
@Override
protected Void doInBackground(Void... voids) {
try {
InetAddress serverAddr = InetAddress.getByName("192.168.100.105");
socket = new Socket(serverAddr,ROVER_PORT);
out = new DataOutputStream(socket.getOutputStream());
log("Connected to Server");
serialConnected = true;
/*Add communication thread*/
(new Thread(new CommunicationThread(socket))).start();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e){
serverConnected = false;
try{
if(out!=null)
out.close();
if(socket!=null)
socket.close();
} catch (IOException e1){
e1.printStackTrace();
} finally {
log(e.getLocalizedMessage());
e.printStackTrace();
}
}
return null;
}
}
public class CommunicationThread implements Runnable{
private Socket clientSocket;
private DataInputStream in;
private int bytesRead;
private static final int BUFFER_LENGTH = 4000;
private byte[] buffer = new byte[BUFFER_LENGTH];
public CommunicationThread(Socket clientSocket) {
this.clientSocket = clientSocket;
try {
this.in = new DataInputStream(this.clientSocket.getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void run() {
while(!Thread.currentThread().isInterrupted()){
try {
System.out.println("Thread is running");
bytesRead = in.read(buffer);
log("Read"+bytesRead+"bytes");
log(new String(buffer,0,bytesRead));
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
class LogTask extends AsyncTask<Void,Void,Void>{
TextView view;
String msg;
public LogTask(TextView view, String msg) {
this.view = view;
this.msg = msg;
}
@Override
protected Void doInBackground(Void... voids) {
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
System.out.println(msg);
String currentLog = view.getText().toString();
String newLog = msg + "\n" + currentLog;
view.setText(newLog);
super.onPostExecute(aVoid);
}
}
| [
"quanghuy_0609@yahoo.com.vn"
] | quanghuy_0609@yahoo.com.vn |
9f735ced14c781c2709631b37633f6b575abfa61 | 147ca3237016436823f3396bc5151f821e56408d | /src/main/java/com/gump/gumphr/config/Fliter.java | dfaf0ed51e5dd35ec3a96ec27847aafd0d08457a | [] | no_license | cooper12138/GUMP-HR | 220816db0b3d5e9014887b7fe459982056269d79 | d9dbeb086d507b585f6b5711bffd5be49f228fc0 | refs/heads/master | 2023-06-17T00:29:22.197845 | 2021-07-14T01:47:29 | 2021-07-14T01:47:29 | 271,593,625 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 762 | java | package com.gump.gumphr.config;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
import java.util.Collection;
/** 根据用户传的请求地址 判断请求需要的角色
* @author gump(zzc)
* @version 1.0
* @date 2020/6/11 23:11
*/
public class Fliter implements FilterInvocationSecurityMetadataSource {
@Override
public Collection<ConfigAttribute> getAttributes(Object o) throws IllegalArgumentException {
return null;
}
@Override
public Collection<ConfigAttribute> getAllConfigAttributes() {
return null;
}
@Override
public boolean supports(Class<?> aClass) {
return false;
}
}
| [
"994739211@qq.com"
] | 994739211@qq.com |
7ce53dfc5875bc42b1f918f4e979c9cf58f0c121 | aeda2e940591028cf012ddaabdcbf694fd3fe3fd | /src/com/qa/vehicle/MotorBike.java | d5039a0eeb7ff726943ac52d5cfd3cbc436b0721 | [] | no_license | samkazshel/Garage_Project | 0517b39e7de7caf0d413187f5b9d0a31fabafc11 | 5efa1bcb4df405600d9cb3a3b7555d5d936a728a | refs/heads/main | 2023-08-12T10:42:20.474766 | 2021-10-12T15:33:36 | 2021-10-12T15:33:36 | 416,277,741 | 0 | 0 | null | 2021-10-12T15:33:09 | 2021-10-12T09:53:23 | Java | UTF-8 | Java | false | false | 884 | java | package com.qa.vehicle;
public class MotorBike extends Vehicle{
private String tires;
private String ridingPosition;
public MotorBike(String model, String regPlate, boolean mOT, String engineSize, String tires,
String ridingPosition) {
super(model, regPlate, mOT, engineSize);
this.tires = tires;
this.ridingPosition = ridingPosition;
}
public String getTires() {
return tires;
}
public void setTires(String tires) {
this.tires = tires;
}
public String getRidingPosition() {
return ridingPosition;
}
public void setRidingPosition(String ridingPosition) {
this.ridingPosition = ridingPosition;
}
@Override
public String toString() {
return "MotorBike [tires=" + tires + ", ridingPosition=" + ridingPosition + ", model=" + model + ", regPlate="
+ regPlate + ", MOT=" + MOT + ", engineSize=" + engineSize + "]";
}
}
| [
"samsheldon779@gmail.com"
] | samsheldon779@gmail.com |
123fd5888055a2a2243c2593153e2a5d839779c3 | 97688ee29f870bb2a3bb291777442cfad85dfb0b | /source_code_4.1.x/spring-core/src/main/java/org/springframework/util/ClassUtils.java | b1fe72d9620db485ef0edc7cd92858742b11c1aa | [
"Apache-2.0"
] | permissive | kolamomo/spring-framework_study | 846ceac48b6637c68dd44eac2c9be78277099cac | b1f372761efc584962ee9b01b3cad6585cf37820 | refs/heads/master | 2020-04-09T07:32:31.042697 | 2016-01-16T06:01:22 | 2016-01-16T06:01:22 | 40,133,046 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 47,153 | java | /*
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.util;
import java.beans.Introspector;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
/**
* Miscellaneous class utility methods.
* Mainly for internal use within the framework.
*
* @author Juergen Hoeller
* @author Keith Donald
* @author Rob Harrop
* @author Sam Brannen
* @since 1.1
* @see TypeUtils
* @see ReflectionUtils
*/
public abstract class ClassUtils {
/** Suffix for array class names: "[]" */
public static final String ARRAY_SUFFIX = "[]";
/** Prefix for internal array class names: "[" */
private static final String INTERNAL_ARRAY_PREFIX = "[";
/** Prefix for internal non-primitive array class names: "[L" */
private static final String NON_PRIMITIVE_ARRAY_PREFIX = "[L";
/** The package separator character '.' */
private static final char PACKAGE_SEPARATOR = '.';
/** The path separator character '/' */
private static final char PATH_SEPARATOR = '/';
/** The inner class separator character '$' */
private static final char INNER_CLASS_SEPARATOR = '$';
/** The CGLIB class separator character "$$" */
public static final String CGLIB_CLASS_SEPARATOR = "$$";
/** The ".class" file suffix */
public static final String CLASS_FILE_SUFFIX = ".class";
/**
* Map with primitive wrapper type as key and corresponding primitive
* type as value, for example: Integer.class -> int.class.
*/
private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new HashMap<Class<?>, Class<?>>(8);
/**
* Map with primitive type as key and corresponding wrapper
* type as value, for example: int.class -> Integer.class.
*/
private static final Map<Class<?>, Class<?>> primitiveTypeToWrapperMap = new HashMap<Class<?>, Class<?>>(8);
/**
* Map with primitive type name as key and corresponding primitive
* type as value, for example: "int" -> "int.class".
*/
private static final Map<String, Class<?>> primitiveTypeNameMap = new HashMap<String, Class<?>>(32);
/**
* Map with common "java.lang" class name as key and corresponding Class as value.
* Primarily for efficient deserialization of remote invocations.
*/
private static final Map<String, Class<?>> commonClassCache = new HashMap<String, Class<?>>(32);
static {
primitiveWrapperTypeMap.put(Boolean.class, boolean.class);
primitiveWrapperTypeMap.put(Byte.class, byte.class);
primitiveWrapperTypeMap.put(Character.class, char.class);
primitiveWrapperTypeMap.put(Double.class, double.class);
primitiveWrapperTypeMap.put(Float.class, float.class);
primitiveWrapperTypeMap.put(Integer.class, int.class);
primitiveWrapperTypeMap.put(Long.class, long.class);
primitiveWrapperTypeMap.put(Short.class, short.class);
for (Map.Entry<Class<?>, Class<?>> entry : primitiveWrapperTypeMap.entrySet()) {
primitiveTypeToWrapperMap.put(entry.getValue(), entry.getKey());
registerCommonClasses(entry.getKey());
}
Set<Class<?>> primitiveTypes = new HashSet<Class<?>>(32);
primitiveTypes.addAll(primitiveWrapperTypeMap.values());
primitiveTypes.addAll(Arrays.asList(new Class<?>[] {
boolean[].class, byte[].class, char[].class, double[].class,
float[].class, int[].class, long[].class, short[].class}));
primitiveTypes.add(void.class);
for (Class<?> primitiveType : primitiveTypes) {
primitiveTypeNameMap.put(primitiveType.getName(), primitiveType);
}
registerCommonClasses(Boolean[].class, Byte[].class, Character[].class, Double[].class,
Float[].class, Integer[].class, Long[].class, Short[].class);
registerCommonClasses(Number.class, Number[].class, String.class, String[].class,
Object.class, Object[].class, Class.class, Class[].class);
registerCommonClasses(Throwable.class, Exception.class, RuntimeException.class,
Error.class, StackTraceElement.class, StackTraceElement[].class);
}
/**
* Register the given common classes with the ClassUtils cache.
*/
private static void registerCommonClasses(Class<?>... commonClasses) {
for (Class<?> clazz : commonClasses) {
commonClassCache.put(clazz.getName(), clazz);
}
}
/**
* Return the default ClassLoader to use: typically the thread context
* ClassLoader, if available; the ClassLoader that loaded the ClassUtils
* class will be used as fallback.
* <p>Call this method if you intend to use the thread context ClassLoader
* in a scenario where you clearly prefer a non-null ClassLoader reference:
* for example, for class path resource loading (but not necessarily for
* {@code Class.forName}, which accepts a {@code null} ClassLoader
* reference as well).
* @return the default ClassLoader (only {@code null} if even the system
* ClassLoader isn't accessible)
* @see Thread#getContextClassLoader()
* @see ClassLoader#getSystemClassLoader()
*/
public static ClassLoader getDefaultClassLoader() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
}
catch (Throwable ex) {
// Cannot access thread context ClassLoader - falling back...
}
if (cl == null) {
// No thread context class loader -> use class loader of this class.
cl = ClassUtils.class.getClassLoader();
if (cl == null) {
// getClassLoader() returning null indicates the bootstrap ClassLoader
try {
cl = ClassLoader.getSystemClassLoader();
}
catch (Throwable ex) {
// Cannot access system ClassLoader - oh well, maybe the caller can live with null...
}
}
}
return cl;
}
/**
* Override the thread context ClassLoader with the environment's bean ClassLoader
* if necessary, i.e. if the bean ClassLoader is not equivalent to the thread
* context ClassLoader already.
* @param classLoaderToUse the actual ClassLoader to use for the thread context
* @return the original thread context ClassLoader, or {@code null} if not overridden
*/
public static ClassLoader overrideThreadContextClassLoader(ClassLoader classLoaderToUse) {
Thread currentThread = Thread.currentThread();
ClassLoader threadContextClassLoader = currentThread.getContextClassLoader();
if (classLoaderToUse != null && !classLoaderToUse.equals(threadContextClassLoader)) {
currentThread.setContextClassLoader(classLoaderToUse);
return threadContextClassLoader;
}
else {
return null;
}
}
/**
* Replacement for {@code Class.forName()} that also returns Class instances
* for primitives (e.g. "int") and array class names (e.g. "String[]").
* Furthermore, it is also capable of resolving inner class names in Java source
* style (e.g. "java.lang.Thread.State" instead of "java.lang.Thread$State").
* @param name the name of the Class
* @param classLoader the class loader to use
* (may be {@code null}, which indicates the default class loader)
* @return Class instance for the supplied name
* @throws ClassNotFoundException if the class was not found
* @throws LinkageError if the class file could not be loaded
* @see Class#forName(String, boolean, ClassLoader)
*/
public static Class<?> forName(String name, ClassLoader classLoader) throws ClassNotFoundException, LinkageError {
Assert.notNull(name, "Name must not be null");
Class<?> clazz = resolvePrimitiveClassName(name);
if (clazz == null) {
clazz = commonClassCache.get(name);
}
if (clazz != null) {
return clazz;
}
// "java.lang.String[]" style arrays
if (name.endsWith(ARRAY_SUFFIX)) {
String elementClassName = name.substring(0, name.length() - ARRAY_SUFFIX.length());
Class<?> elementClass = forName(elementClassName, classLoader);
return Array.newInstance(elementClass, 0).getClass();
}
// "[Ljava.lang.String;" style arrays
if (name.startsWith(NON_PRIMITIVE_ARRAY_PREFIX) && name.endsWith(";")) {
String elementName = name.substring(NON_PRIMITIVE_ARRAY_PREFIX.length(), name.length() - 1);
Class<?> elementClass = forName(elementName, classLoader);
return Array.newInstance(elementClass, 0).getClass();
}
// "[[I" or "[[Ljava.lang.String;" style arrays
if (name.startsWith(INTERNAL_ARRAY_PREFIX)) {
String elementName = name.substring(INTERNAL_ARRAY_PREFIX.length());
Class<?> elementClass = forName(elementName, classLoader);
return Array.newInstance(elementClass, 0).getClass();
}
ClassLoader clToUse = classLoader;
if (clToUse == null) {
clToUse = getDefaultClassLoader();
}
try {
return (clToUse != null ? clToUse.loadClass(name) : Class.forName(name));
}
catch (ClassNotFoundException ex) {
int lastDotIndex = name.lastIndexOf(PACKAGE_SEPARATOR);
if (lastDotIndex != -1) {
String innerClassName =
name.substring(0, lastDotIndex) + INNER_CLASS_SEPARATOR + name.substring(lastDotIndex + 1);
try {
return (clToUse != null ? clToUse.loadClass(innerClassName) : Class.forName(innerClassName));
}
catch (ClassNotFoundException ex2) {
// Swallow - let original exception get through
}
}
throw ex;
}
}
/**
* Resolve the given class name into a Class instance. Supports
* primitives (like "int") and array class names (like "String[]").
* <p>This is effectively equivalent to the {@code forName}
* method with the same arguments, with the only difference being
* the exceptions thrown in case of class loading failure.
* @param className the name of the Class
* @param classLoader the class loader to use
* (may be {@code null}, which indicates the default class loader)
* @return Class instance for the supplied name
* @throws IllegalArgumentException if the class name was not resolvable
* (that is, the class could not be found or the class file could not be loaded)
* @see #forName(String, ClassLoader)
*/
public static Class<?> resolveClassName(String className, ClassLoader classLoader) throws IllegalArgumentException {
try {
return forName(className, classLoader);
}
catch (ClassNotFoundException ex) {
throw new IllegalArgumentException("Cannot find class [" + className + "]", ex);
}
catch (LinkageError ex) {
throw new IllegalArgumentException(
"Error loading class [" + className + "]: problem with class file or dependent class.", ex);
}
}
/**
* Resolve the given class name as primitive class, if appropriate,
* according to the JVM's naming rules for primitive classes.
* <p>Also supports the JVM's internal class names for primitive arrays.
* Does <i>not</i> support the "[]" suffix notation for primitive arrays;
* this is only supported by {@link #forName(String, ClassLoader)}.
* @param name the name of the potentially primitive class
* @return the primitive class, or {@code null} if the name does not denote
* a primitive class or primitive array class
*/
public static Class<?> resolvePrimitiveClassName(String name) {
Class<?> result = null;
// Most class names will be quite long, considering that they
// SHOULD sit in a package, so a length check is worthwhile.
if (name != null && name.length() <= 8) {
// Could be a primitive - likely.
result = primitiveTypeNameMap.get(name);
}
return result;
}
/**
* Determine whether the {@link Class} identified by the supplied name is present
* and can be loaded. Will return {@code false} if either the class or
* one of its dependencies is not present or cannot be loaded.
* @param className the name of the class to check
* @param classLoader the class loader to use
* (may be {@code null}, which indicates the default class loader)
* @return whether the specified class is present
*/
public static boolean isPresent(String className, ClassLoader classLoader) {
try {
forName(className, classLoader);
return true;
}
catch (Throwable ex) {
// Class or one of its dependencies is not present...
return false;
}
}
/**
* Return the user-defined class for the given instance: usually simply
* the class of the given instance, but the original class in case of a
* CGLIB-generated subclass.
* @param instance the instance to check
* @return the user-defined class
*/
public static Class<?> getUserClass(Object instance) {
Assert.notNull(instance, "Instance must not be null");
return getUserClass(instance.getClass());
}
/**
* Return the user-defined class for the given class: usually simply the given
* class, but the original class in case of a CGLIB-generated subclass.
* @param clazz the class to check
* @return the user-defined class
*/
public static Class<?> getUserClass(Class<?> clazz) {
if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
Class<?> superclass = clazz.getSuperclass();
if (superclass != null && !Object.class.equals(superclass)) {
return superclass;
}
}
return clazz;
}
/**
* Check whether the given class is cache-safe in the given context,
* i.e. whether it is loaded by the given ClassLoader or a parent of it.
* @param clazz the class to analyze
* @param classLoader the ClassLoader to potentially cache metadata in
*/
public static boolean isCacheSafe(Class<?> clazz, ClassLoader classLoader) {
Assert.notNull(clazz, "Class must not be null");
try {
ClassLoader target = clazz.getClassLoader();
if (target == null) {
return true;
}
ClassLoader cur = classLoader;
if (cur == target) {
return true;
}
while (cur != null) {
cur = cur.getParent();
if (cur == target) {
return true;
}
}
return false;
}
catch (SecurityException ex) {
// Probably from the system ClassLoader - let's consider it safe.
return true;
}
}
/**
* Get the class name without the qualified package name.
* @param className the className to get the short name for
* @return the class name of the class without the package name
* @throws IllegalArgumentException if the className is empty
*/
public static String getShortName(String className) {
Assert.hasLength(className, "Class name must not be empty");
int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
int nameEndIndex = className.indexOf(CGLIB_CLASS_SEPARATOR);
if (nameEndIndex == -1) {
nameEndIndex = className.length();
}
String shortName = className.substring(lastDotIndex + 1, nameEndIndex);
shortName = shortName.replace(INNER_CLASS_SEPARATOR, PACKAGE_SEPARATOR);
return shortName;
}
/**
* Get the class name without the qualified package name.
* @param clazz the class to get the short name for
* @return the class name of the class without the package name
*/
public static String getShortName(Class<?> clazz) {
return getShortName(getQualifiedName(clazz));
}
/**
* Return the short string name of a Java class in uncapitalized JavaBeans
* property format. Strips the outer class name in case of an inner class.
* @param clazz the class
* @return the short name rendered in a standard JavaBeans property format
* @see java.beans.Introspector#decapitalize(String)
*/
public static String getShortNameAsProperty(Class<?> clazz) {
String shortName = ClassUtils.getShortName(clazz);
int dotIndex = shortName.lastIndexOf(PACKAGE_SEPARATOR);
shortName = (dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName);
return Introspector.decapitalize(shortName);
}
/**
* Determine the name of the class file, relative to the containing
* package: e.g. "String.class"
* @param clazz the class
* @return the file name of the ".class" file
*/
public static String getClassFileName(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
String className = clazz.getName();
int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
return className.substring(lastDotIndex + 1) + CLASS_FILE_SUFFIX;
}
/**
* Determine the name of the package of the given class,
* e.g. "java.lang" for the {@code java.lang.String} class.
* @param clazz the class
* @return the package name, or the empty String if the class
* is defined in the default package
*/
public static String getPackageName(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return getPackageName(clazz.getName());
}
/**
* Determine the name of the package of the given fully-qualified class name,
* e.g. "java.lang" for the {@code java.lang.String} class name.
* @param fqClassName the fully-qualified class name
* @return the package name, or the empty String if the class
* is defined in the default package
*/
public static String getPackageName(String fqClassName) {
Assert.notNull(fqClassName, "Class name must not be null");
int lastDotIndex = fqClassName.lastIndexOf(PACKAGE_SEPARATOR);
return (lastDotIndex != -1 ? fqClassName.substring(0, lastDotIndex) : "");
}
/**
* Return the qualified name of the given class: usually simply
* the class name, but component type class name + "[]" for arrays.
* @param clazz the class
* @return the qualified name of the class
*/
public static String getQualifiedName(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
if (clazz.isArray()) {
return getQualifiedNameForArray(clazz);
}
else {
return clazz.getName();
}
}
/**
* Build a nice qualified name for an array:
* component type class name + "[]".
* @param clazz the array class
* @return a qualified name for the array class
*/
private static String getQualifiedNameForArray(Class<?> clazz) {
StringBuilder result = new StringBuilder();
while (clazz.isArray()) {
clazz = clazz.getComponentType();
result.append(ClassUtils.ARRAY_SUFFIX);
}
result.insert(0, clazz.getName());
return result.toString();
}
/**
* Return the qualified name of the given method, consisting of
* fully qualified interface/class name + "." + method name.
* @param method the method
* @return the qualified name of the method
*/
public static String getQualifiedMethodName(Method method) {
Assert.notNull(method, "Method must not be null");
return method.getDeclaringClass().getName() + "." + method.getName();
}
/**
* Return a descriptive name for the given object's type: usually simply
* the class name, but component type class name + "[]" for arrays,
* and an appended list of implemented interfaces for JDK proxies.
* @param value the value to introspect
* @return the qualified name of the class
*/
public static String getDescriptiveType(Object value) {
if (value == null) {
return null;
}
Class<?> clazz = value.getClass();
if (Proxy.isProxyClass(clazz)) {
StringBuilder result = new StringBuilder(clazz.getName());
result.append(" implementing ");
Class<?>[] ifcs = clazz.getInterfaces();
for (int i = 0; i < ifcs.length; i++) {
result.append(ifcs[i].getName());
if (i < ifcs.length - 1) {
result.append(',');
}
}
return result.toString();
}
else if (clazz.isArray()) {
return getQualifiedNameForArray(clazz);
}
else {
return clazz.getName();
}
}
/**
* Check whether the given class matches the user-specified type name.
* @param clazz the class to check
* @param typeName the type name to match
*/
public static boolean matchesTypeName(Class<?> clazz, String typeName) {
return (typeName != null &&
(typeName.equals(clazz.getName()) || typeName.equals(clazz.getSimpleName()) ||
(clazz.isArray() && typeName.equals(getQualifiedNameForArray(clazz)))));
}
/**
* Determine whether the given class has a public constructor with the given signature.
* <p>Essentially translates {@code NoSuchMethodException} to "false".
* @param clazz the clazz to analyze
* @param paramTypes the parameter types of the method
* @return whether the class has a corresponding constructor
* @see Class#getMethod
*/
public static boolean hasConstructor(Class<?> clazz, Class<?>... paramTypes) {
return (getConstructorIfAvailable(clazz, paramTypes) != null);
}
/**
* Determine whether the given class has a public constructor with the given signature,
* and return it if available (else return {@code null}).
* <p>Essentially translates {@code NoSuchMethodException} to {@code null}.
* @param clazz the clazz to analyze
* @param paramTypes the parameter types of the method
* @return the constructor, or {@code null} if not found
* @see Class#getConstructor
*/
public static <T> Constructor<T> getConstructorIfAvailable(Class<T> clazz, Class<?>... paramTypes) {
Assert.notNull(clazz, "Class must not be null");
try {
return clazz.getConstructor(paramTypes);
}
catch (NoSuchMethodException ex) {
return null;
}
}
/**
* Determine whether the given class has a public method with the given signature.
* <p>Essentially translates {@code NoSuchMethodException} to "false".
* @param clazz the clazz to analyze
* @param methodName the name of the method
* @param paramTypes the parameter types of the method
* @return whether the class has a corresponding method
* @see Class#getMethod
*/
public static boolean hasMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
return (getMethodIfAvailable(clazz, methodName, paramTypes) != null);
}
/**
* Determine whether the given class has a public method with the given signature,
* and return it if available (else throws an {@code IllegalStateException}).
* <p>In case of any signature specified, only returns the method if there is a
* unique candidate, i.e. a single public method with the specified name.
* <p>Essentially translates {@code NoSuchMethodException} to {@code IllegalStateException}.
* @param clazz the clazz to analyze
* @param methodName the name of the method
* @param paramTypes the parameter types of the method
* (may be {@code null} to indicate any signature)
* @return the method (never {@code null})
* @throws IllegalStateException if the method has not been found
* @see Class#getMethod
*/
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
if (paramTypes != null) {
try {
return clazz.getMethod(methodName, paramTypes);
}
catch (NoSuchMethodException ex) {
throw new IllegalStateException("Expected method not found: " + ex);
}
}
else {
Set<Method> candidates = new HashSet<Method>(1);
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (methodName.equals(method.getName())) {
candidates.add(method);
}
}
if (candidates.size() == 1) {
return candidates.iterator().next();
}
else if (candidates.isEmpty()) {
throw new IllegalStateException("Expected method not found: " + clazz + "." + methodName);
}
else {
throw new IllegalStateException("No unique method found: " + clazz + "." + methodName);
}
}
}
/**
* Determine whether the given class has a public method with the given signature,
* and return it if available (else return {@code null}).
* <p>In case of any signature specified, only returns the method if there is a
* unique candidate, i.e. a single public method with the specified name.
* <p>Essentially translates {@code NoSuchMethodException} to {@code null}.
* @param clazz the clazz to analyze
* @param methodName the name of the method
* @param paramTypes the parameter types of the method
* (may be {@code null} to indicate any signature)
* @return the method, or {@code null} if not found
* @see Class#getMethod
*/
public static Method getMethodIfAvailable(Class<?> clazz, String methodName, Class<?>... paramTypes) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
if (paramTypes != null) {
try {
return clazz.getMethod(methodName, paramTypes);
}
catch (NoSuchMethodException ex) {
return null;
}
}
else {
Set<Method> candidates = new HashSet<Method>(1);
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (methodName.equals(method.getName())) {
candidates.add(method);
}
}
if (candidates.size() == 1) {
return candidates.iterator().next();
}
return null;
}
}
/**
* Return the number of methods with a given name (with any argument types),
* for the given class and/or its superclasses. Includes non-public methods.
* @param clazz the clazz to check
* @param methodName the name of the method
* @return the number of methods with the given name
*/
public static int getMethodCountForName(Class<?> clazz, String methodName) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
int count = 0;
Method[] declaredMethods = clazz.getDeclaredMethods();
for (Method method : declaredMethods) {
if (methodName.equals(method.getName())) {
count++;
}
}
Class<?>[] ifcs = clazz.getInterfaces();
for (Class<?> ifc : ifcs) {
count += getMethodCountForName(ifc, methodName);
}
if (clazz.getSuperclass() != null) {
count += getMethodCountForName(clazz.getSuperclass(), methodName);
}
return count;
}
/**
* Does the given class or one of its superclasses at least have one or more
* methods with the supplied name (with any argument types)?
* Includes non-public methods.
* @param clazz the clazz to check
* @param methodName the name of the method
* @return whether there is at least one method with the given name
*/
public static boolean hasAtLeastOneMethodWithName(Class<?> clazz, String methodName) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
Method[] declaredMethods = clazz.getDeclaredMethods();
for (Method method : declaredMethods) {
if (method.getName().equals(methodName)) {
return true;
}
}
Class<?>[] ifcs = clazz.getInterfaces();
for (Class<?> ifc : ifcs) {
if (hasAtLeastOneMethodWithName(ifc, methodName)) {
return true;
}
}
return (clazz.getSuperclass() != null && hasAtLeastOneMethodWithName(clazz.getSuperclass(), methodName));
}
/**
* Given a method, which may come from an interface, and a target class used
* in the current reflective invocation, find the corresponding target method
* if there is one. E.g. the method may be {@code IFoo.bar()} and the
* target class may be {@code DefaultFoo}. In this case, the method may be
* {@code DefaultFoo.bar()}. This enables attributes on that method to be found.
* <p><b>NOTE:</b> In contrast to {@link org.springframework.aop.support.AopUtils#getMostSpecificMethod},
* this method does <i>not</i> resolve Java 5 bridge methods automatically.
* Call {@link org.springframework.core.BridgeMethodResolver#findBridgedMethod}
* if bridge method resolution is desirable (e.g. for obtaining metadata from
* the original method definition).
* <p><b>NOTE:</b> Since Spring 3.1.1, if Java security settings disallow reflective
* access (e.g. calls to {@code Class#getDeclaredMethods} etc, this implementation
* will fall back to returning the originally provided method.
* @param method the method to be invoked, which may come from an interface
* @param targetClass the target class for the current invocation.
* May be {@code null} or may not even implement the method.
* @return the specific target method, or the original method if the
* {@code targetClass} doesn't implement it or is {@code null}
*/
public static Method getMostSpecificMethod(Method method, Class<?> targetClass) {
if (method != null && isOverridable(method, targetClass) &&
targetClass != null && !targetClass.equals(method.getDeclaringClass())) {
try {
if (Modifier.isPublic(method.getModifiers())) {
try {
return targetClass.getMethod(method.getName(), method.getParameterTypes());
}
catch (NoSuchMethodException ex) {
return method;
}
}
else {
Method specificMethod =
ReflectionUtils.findMethod(targetClass, method.getName(), method.getParameterTypes());
return (specificMethod != null ? specificMethod : method);
}
}
catch (SecurityException ex) {
// Security settings are disallowing reflective access; fall back to 'method' below.
}
}
return method;
}
/**
* Determine whether the given method is declared by the user or at least pointing to
* a user-declared method.
* <p>Checks {@link Method#isSynthetic()} (for implementation methods) as well as the
* {@code GroovyObject} interface (for interface methods; on an implementation class,
* implementations of the {@code GroovyObject} methods will be marked as synthetic anyway).
* Note that, despite being synthetic, bridge methods ({@link Method#isBridge()}) are considered
* as user-level methods since they are eventually pointing to a user-declared generic method.
* @param method the method to check
* @return {@code true} if the method can be considered as user-declared; [@code false} otherwise
*/
public static boolean isUserLevelMethod(Method method) {
Assert.notNull(method, "Method must not be null");
return (method.isBridge() || (!method.isSynthetic() && !isGroovyObjectMethod(method)));
}
private static boolean isGroovyObjectMethod(Method method) {
return method.getDeclaringClass().getName().equals("groovy.lang.GroovyObject");
}
/**
* Determine whether the given method is overridable in the given target class.
* @param method the method to check
* @param targetClass the target class to check against
*/
private static boolean isOverridable(Method method, Class<?> targetClass) {
if (Modifier.isPrivate(method.getModifiers())) {
return false;
}
if (Modifier.isPublic(method.getModifiers()) || Modifier.isProtected(method.getModifiers())) {
return true;
}
return getPackageName(method.getDeclaringClass()).equals(getPackageName(targetClass));
}
/**
* Return a public static method of a class.
* @param clazz the class which defines the method
* @param methodName the static method name
* @param args the parameter types to the method
* @return the static method, or {@code null} if no static method was found
* @throws IllegalArgumentException if the method name is blank or the clazz is null
*/
public static Method getStaticMethod(Class<?> clazz, String methodName, Class<?>... args) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
try {
Method method = clazz.getMethod(methodName, args);
return Modifier.isStatic(method.getModifiers()) ? method : null;
}
catch (NoSuchMethodException ex) {
return null;
}
}
/**
* Check if the given class represents a primitive wrapper,
* i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double.
* @param clazz the class to check
* @return whether the given class is a primitive wrapper class
*/
public static boolean isPrimitiveWrapper(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return primitiveWrapperTypeMap.containsKey(clazz);
}
/**
* Check if the given class represents a primitive (i.e. boolean, byte,
* char, short, int, long, float, or double) or a primitive wrapper
* (i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double).
* @param clazz the class to check
* @return whether the given class is a primitive or primitive wrapper class
*/
public static boolean isPrimitiveOrWrapper(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isPrimitive() || isPrimitiveWrapper(clazz));
}
/**
* Check if the given class represents an array of primitives,
* i.e. boolean, byte, char, short, int, long, float, or double.
* @param clazz the class to check
* @return whether the given class is a primitive array class
*/
public static boolean isPrimitiveArray(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isArray() && clazz.getComponentType().isPrimitive());
}
/**
* Check if the given class represents an array of primitive wrappers,
* i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double.
* @param clazz the class to check
* @return whether the given class is a primitive wrapper array class
*/
public static boolean isPrimitiveWrapperArray(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isArray() && isPrimitiveWrapper(clazz.getComponentType()));
}
/**
* Resolve the given class if it is a primitive class,
* returning the corresponding primitive wrapper type instead.
* @param clazz the class to check
* @return the original class, or a primitive wrapper for the original primitive type
*/
public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isPrimitive() && clazz != void.class ? primitiveTypeToWrapperMap.get(clazz) : clazz);
}
/**
* Check if the right-hand side type may be assigned to the left-hand side
* type, assuming setting by reflection. Considers primitive wrapper
* classes as assignable to the corresponding primitive types.
* @param lhsType the target type
* @param rhsType the value type that should be assigned to the target type
* @return if the target type is assignable from the value type
* @see TypeUtils#isAssignable
*/
public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) {
Assert.notNull(lhsType, "Left-hand side type must not be null");
Assert.notNull(rhsType, "Right-hand side type must not be null");
if (lhsType.isAssignableFrom(rhsType)) {
return true;
}
if (lhsType.isPrimitive()) {
Class<?> resolvedPrimitive = primitiveWrapperTypeMap.get(rhsType);
if (resolvedPrimitive != null && lhsType.equals(resolvedPrimitive)) {
return true;
}
}
else {
Class<?> resolvedWrapper = primitiveTypeToWrapperMap.get(rhsType);
if (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)) {
return true;
}
}
return false;
}
/**
* Determine if the given type is assignable from the given value,
* assuming setting by reflection. Considers primitive wrapper classes
* as assignable to the corresponding primitive types.
* @param type the target type
* @param value the value that should be assigned to the type
* @return if the type is assignable from the value
*/
public static boolean isAssignableValue(Class<?> type, Object value) {
Assert.notNull(type, "Type must not be null");
return (value != null ? isAssignable(type, value.getClass()) : !type.isPrimitive());
}
/**
* Convert a "/"-based resource path to a "."-based fully qualified class name.
* @param resourcePath the resource path pointing to a class
* @return the corresponding fully qualified class name
*/
public static String convertResourcePathToClassName(String resourcePath) {
Assert.notNull(resourcePath, "Resource path must not be null");
return resourcePath.replace(PATH_SEPARATOR, PACKAGE_SEPARATOR);
}
/**
* Convert a "."-based fully qualified class name to a "/"-based resource path.
* @param className the fully qualified class name
* @return the corresponding resource path, pointing to the class
*/
public static String convertClassNameToResourcePath(String className) {
Assert.notNull(className, "Class name must not be null");
return className.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
}
/**
* Return a path suitable for use with {@code ClassLoader.getResource}
* (also suitable for use with {@code Class.getResource} by prepending a
* slash ('/') to the return value). Built by taking the package of the specified
* class file, converting all dots ('.') to slashes ('/'), adding a trailing slash
* if necessary, and concatenating the specified resource name to this.
* <br/>As such, this function may be used to build a path suitable for
* loading a resource file that is in the same package as a class file,
* although {@link org.springframework.core.io.ClassPathResource} is usually
* even more convenient.
* @param clazz the Class whose package will be used as the base
* @param resourceName the resource name to append. A leading slash is optional.
* @return the built-up resource path
* @see ClassLoader#getResource
* @see Class#getResource
*/
public static String addResourcePathToPackagePath(Class<?> clazz, String resourceName) {
Assert.notNull(resourceName, "Resource name must not be null");
if (!resourceName.startsWith("/")) {
return classPackageAsResourcePath(clazz) + "/" + resourceName;
}
return classPackageAsResourcePath(clazz) + resourceName;
}
/**
* Given an input class object, return a string which consists of the
* class's package name as a pathname, i.e., all dots ('.') are replaced by
* slashes ('/'). Neither a leading nor trailing slash is added. The result
* could be concatenated with a slash and the name of a resource and fed
* directly to {@code ClassLoader.getResource()}. For it to be fed to
* {@code Class.getResource} instead, a leading slash would also have
* to be prepended to the returned value.
* @param clazz the input class. A {@code null} value or the default
* (empty) package will result in an empty string ("") being returned.
* @return a path which represents the package name
* @see ClassLoader#getResource
* @see Class#getResource
*/
public static String classPackageAsResourcePath(Class<?> clazz) {
if (clazz == null) {
return "";
}
String className = clazz.getName();
int packageEndIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
if (packageEndIndex == -1) {
return "";
}
String packageName = className.substring(0, packageEndIndex);
return packageName.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
}
/**
* Build a String that consists of the names of the classes/interfaces
* in the given array.
* <p>Basically like {@code AbstractCollection.toString()}, but stripping
* the "class "/"interface " prefix before every class name.
* @param classes a Collection of Class objects (may be {@code null})
* @return a String of form "[com.foo.Bar, com.foo.Baz]"
* @see java.util.AbstractCollection#toString()
*/
public static String classNamesToString(Class<?>... classes) {
return classNamesToString(Arrays.asList(classes));
}
/**
* Build a String that consists of the names of the classes/interfaces
* in the given collection.
* <p>Basically like {@code AbstractCollection.toString()}, but stripping
* the "class "/"interface " prefix before every class name.
* @param classes a Collection of Class objects (may be {@code null})
* @return a String of form "[com.foo.Bar, com.foo.Baz]"
* @see java.util.AbstractCollection#toString()
*/
public static String classNamesToString(Collection<Class<?>> classes) {
if (CollectionUtils.isEmpty(classes)) {
return "[]";
}
StringBuilder sb = new StringBuilder("[");
for (Iterator<Class<?>> it = classes.iterator(); it.hasNext(); ) {
Class<?> clazz = it.next();
sb.append(clazz.getName());
if (it.hasNext()) {
sb.append(", ");
}
}
sb.append("]");
return sb.toString();
}
/**
* Copy the given Collection into a Class array.
* The Collection must contain Class elements only.
* @param collection the Collection to copy
* @return the Class array ({@code null} if the passed-in
* Collection was {@code null})
*/
public static Class<?>[] toClassArray(Collection<Class<?>> collection) {
if (collection == null) {
return null;
}
return collection.toArray(new Class<?>[collection.size()]);
}
/**
* Return all interfaces that the given instance implements as array,
* including ones implemented by superclasses.
* @param instance the instance to analyze for interfaces
* @return all interfaces that the given instance implements as array
*/
public static Class<?>[] getAllInterfaces(Object instance) {
Assert.notNull(instance, "Instance must not be null");
return getAllInterfacesForClass(instance.getClass());
}
/**
* Return all interfaces that the given class implements as array,
* including ones implemented by superclasses.
* <p>If the class itself is an interface, it gets returned as sole interface.
* @param clazz the class to analyze for interfaces
* @return all interfaces that the given object implements as array
*/
public static Class<?>[] getAllInterfacesForClass(Class<?> clazz) {
return getAllInterfacesForClass(clazz, null);
}
/**
* Return all interfaces that the given class implements as array,
* including ones implemented by superclasses.
* <p>If the class itself is an interface, it gets returned as sole interface.
* @param clazz the class to analyze for interfaces
* @param classLoader the ClassLoader that the interfaces need to be visible in
* (may be {@code null} when accepting all declared interfaces)
* @return all interfaces that the given object implements as array
*/
public static Class<?>[] getAllInterfacesForClass(Class<?> clazz, ClassLoader classLoader) {
Set<Class<?>> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader);
return ifcs.toArray(new Class<?>[ifcs.size()]);
}
/**
* Return all interfaces that the given instance implements as Set,
* including ones implemented by superclasses.
* @param instance the instance to analyze for interfaces
* @return all interfaces that the given instance implements as Set
*/
public static Set<Class<?>> getAllInterfacesAsSet(Object instance) {
Assert.notNull(instance, "Instance must not be null");
return getAllInterfacesForClassAsSet(instance.getClass());
}
/**
* Return all interfaces that the given class implements as Set,
* including ones implemented by superclasses.
* <p>If the class itself is an interface, it gets returned as sole interface.
* @param clazz the class to analyze for interfaces
* @return all interfaces that the given object implements as Set
*/
public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz) {
return getAllInterfacesForClassAsSet(clazz, null);
}
/**
* Return all interfaces that the given class implements as Set,
* including ones implemented by superclasses.
* <p>If the class itself is an interface, it gets returned as sole interface.
* @param clazz the class to analyze for interfaces
* @param classLoader the ClassLoader that the interfaces need to be visible in
* (may be {@code null} when accepting all declared interfaces)
* @return all interfaces that the given object implements as Set
*/
public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz, ClassLoader classLoader) {
Assert.notNull(clazz, "Class must not be null");
if (clazz.isInterface() && isVisible(clazz, classLoader)) {
return Collections.<Class<?>>singleton(clazz);
}
Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
while (clazz != null) {
Class<?>[] ifcs = clazz.getInterfaces();
for (Class<?> ifc : ifcs) {
interfaces.addAll(getAllInterfacesForClassAsSet(ifc, classLoader));
}
clazz = clazz.getSuperclass();
}
return interfaces;
}
/**
* Create a composite interface Class for the given interfaces,
* implementing the given interfaces in one single Class.
* <p>This implementation builds a JDK proxy class for the given interfaces.
* @param interfaces the interfaces to merge
* @param classLoader the ClassLoader to create the composite Class in
* @return the merged interface as Class
* @see java.lang.reflect.Proxy#getProxyClass
*/
public static Class<?> createCompositeInterface(Class<?>[] interfaces, ClassLoader classLoader) {
Assert.notEmpty(interfaces, "Interfaces must not be empty");
Assert.notNull(classLoader, "ClassLoader must not be null");
return Proxy.getProxyClass(classLoader, interfaces);
}
/**
* Determine the common ancestor of the given classes, if any.
* @param clazz1 the class to introspect
* @param clazz2 the other class to introspect
* @return the common ancestor (i.e. common superclass, one interface
* extending the other), or {@code null} if none found. If any of the
* given classes is {@code null}, the other class will be returned.
* @since 3.2.6
*/
public static Class<?> determineCommonAncestor(Class<?> clazz1, Class<?> clazz2) {
if (clazz1 == null) {
return clazz2;
}
if (clazz2 == null) {
return clazz1;
}
if (clazz1.isAssignableFrom(clazz2)) {
return clazz1;
}
if (clazz2.isAssignableFrom(clazz1)) {
return clazz2;
}
Class<?> ancestor = clazz1;
do {
ancestor = ancestor.getSuperclass();
if (ancestor == null || Object.class.equals(ancestor)) {
return null;
}
}
while (!ancestor.isAssignableFrom(clazz2));
return ancestor;
}
/**
* Check whether the given class is visible in the given ClassLoader.
* @param clazz the class to check (typically an interface)
* @param classLoader the ClassLoader to check against (may be {@code null},
* in which case this method will always return {@code true})
*/
public static boolean isVisible(Class<?> clazz, ClassLoader classLoader) {
if (classLoader == null) {
return true;
}
try {
Class<?> actualClass = classLoader.loadClass(clazz.getName());
return (clazz == actualClass);
// Else: different interface class found...
}
catch (ClassNotFoundException ex) {
// No interface class found...
return false;
}
}
/**
* Check whether the given object is a CGLIB proxy.
* @param object the object to check
* @see org.springframework.aop.support.AopUtils#isCglibProxy(Object)
*/
public static boolean isCglibProxy(Object object) {
return ClassUtils.isCglibProxyClass(object.getClass());
}
/**
* Check whether the specified class is a CGLIB-generated class.
* @param clazz the class to check
*/
public static boolean isCglibProxyClass(Class<?> clazz) {
return (clazz != null && isCglibProxyClassName(clazz.getName()));
}
/**
* Check whether the specified class name is a CGLIB-generated class.
* @param className the class name to check
*/
public static boolean isCglibProxyClassName(String className) {
return (className != null && className.contains(CGLIB_CLASS_SEPARATOR));
}
}
| [
"jayloveyun@163.com"
] | jayloveyun@163.com |
5c27e3e091854a0671e40d075ff2bdd155ce1a74 | 237c1c1c710c23a4170719af0f59ecfe86c6b392 | /src/poo/PruebaTemporizador2.java | ca959bba17a5a3b9121ee3aa486022c9c3508c83 | [] | no_license | maguero73/CursoJava | 225de979d4711d5e58771fd9abaca24ffff7bdf9 | be67e21b5f919bc3847b05f238776f84f894312d | refs/heads/master | 2023-07-29T20:38:41.270990 | 2021-09-07T20:12:37 | 2021-09-07T20:12:37 | 293,636,305 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,430 | java | package poo;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.Timer;
import java.awt.Toolkit;
public class PruebaTemporizador2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//INVOCAMOS AL CONSTRUCTOR
Reloj miReloj=new Reloj(3000, true);
miReloj.enMarcha();
//CREAMOS VENTANA EN PRIMER PLANO PARA QUE PROGRAMA NO TERMINE
JOptionPane.showMessageDialog(null, "Pulsa Aceptar para detener");
System.out.println("El programa se ha terminado");
System.exit(0);
}
}
class Reloj{
//Elaboramos el Constructor
public Reloj(int intervalo, boolean sonido){
this.intervalo= intervalo;
this.sonido= sonido;
}
public void enMarcha(){ //SETTER
ActionListener oyente=new DameLaHora2();
Timer miTemporizador=new Timer(intervalo, oyente);
miTemporizador.start();
}
//fijarse que estas variables de clase engloban a la subclase
//la ventaja es que puede acceder aunque esten encapsulados
private int intervalo;
private boolean sonido;
//CREAMOS LA CLASE INTERNA DENTRO DE LA CLASE RELOJ
private class DameLaHora2 implements ActionListener{
public void actionPerformed(ActionEvent evento){
Date ahora=new Date();
System.out.println("te pongo la hora cada 3 segundos " + ahora);
if(sonido){
Toolkit.getDefaultToolkit().beep();
}
}
}
}
| [
"maguerotecnico@gmail.com"
] | maguerotecnico@gmail.com |
11d38737459359d32d7822dcc066be51db9fee96 | 0e7a8943d743a26ff5ede167b97045e9a5dbf646 | /WalkToRemember2.java | 4ec10a71db853ad4b8ddc6946db78f774fa73dbf | [] | no_license | mooncrater31/Competitive-Programming | dd7657eda25b269ec3873cc78920fb87edbccc41 | 7cf2c8fc00e24d1575f8b1ebb1136a01d393979a | refs/heads/master | 2020-03-31T04:32:20.498065 | 2020-01-19T09:58:38 | 2020-01-19T09:58:38 | 151,909,755 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,572 | java | import java.util.* ;
import java.io.BufferedReader ;
import java.io.InputStreamReader ;
public class WalkToRemember2
{
public static void main(String args[]) throws Exception,InterruptedException,java.io.IOException
{
Thread t = new Thread(null,null,"TT",10000000){
@Override
public void run()
{
try
{
BufferedReader bro = new BufferedReader(new InputStreamReader(System.in)) ;
String[] S = bro.readLine().split(" ") ;
int n = Integer.parseInt(S[0]) ;
int m = Integer.parseInt(S[1]) ;
List<List<Integer>> L = new ArrayList<List<Integer>>() ;
for(int i=0;i<n;i++)
{
L.add(new ArrayList<Integer>()) ;
}
for(int i=0;i<m;i++)
{
S = bro.readLine().split(" ") ;
int a = Integer.parseInt(S[0]) ;
int b = Integer.parseInt(S[1]) ;
L.get(a-1).add(b-1) ;
}
boolean[] visit = new boolean[n] ;
ArrayDeque<Integer> DQ = new ArrayDeque<Integer>() ;
for(int i=0;i<n;i++)
{
if(!visit[i])
{
dfs1(i,L,DQ,visit) ;
}
}
List<List<Integer>> RL = transpose(L) ;
int[] ans = dfs2(RL,DQ) ;
for(int i=0;i<n;i++)
{
System.out.print(ans[i]+" ") ;
}
}
catch(StackOverflowError e)
{
System.err.println("Fuck.") ;
}
catch(java.io.IOException e)
{
System.err.println("Fuck.") ;
}
}
};
t.start() ;
t.join() ;
}
static void dfs1(int s,List<List<Integer>> L,ArrayDeque<Integer> DQ,boolean[] visit)
{
visit[s] = true ;
// int count =1 ;
for(int i=0;i<L.get(s).size();i++)
{
int val = L.get(s).get(i) ;
if(!visit[val])
{
dfs1(val,L,DQ,visit) ;
}
}
DQ.push(s) ;
// return count ;
}
static List<List<Integer>> transpose(List<List<Integer>> L)
{
List<List<Integer>> RL = new ArrayList<List<Integer>>() ;
int n = L.size() ;
for(int i=0;i<n;i++)
{
RL.add(new ArrayList<Integer>()) ;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<L.get(i).size();j++)
{
RL.get(L.get(i).get(j)).add(i) ;
}
}
return RL ;
}
static int[] dfs2(List<List<Integer>> RL,ArrayDeque<Integer> DQ)
{
boolean[] visit = new boolean[RL.size()] ;
int[] ans = new int[RL.size()] ;
while(!DQ.isEmpty())
{
int val = DQ.pop() ;
if(visit[val])
continue ;
else
{
ArrayDeque<Integer> dq = new ArrayDeque<Integer>() ;
dfs1(val,RL,dq,visit) ;
if(dq.size()==1)
ans[val] = 0 ;
else
{
while(!dq.isEmpty())
{
ans[dq.pop()] = 1 ;
}
}
}
}
return ans ;
}
} | [
"mooncraterrocks@gmail.com"
] | mooncraterrocks@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.