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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
46d7e9dc5fbbcd514863123b1bb9af3518602c08 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mm/classes.jar/com/tencent/mm/plugin/webview/ui/tools/jsapi/b.java | 682c807ccb5986d6c5ba79ccfc0e86e2c179ed07 | [] | no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 2,517 | java | package com.tencent.mm.plugin.webview.ui.tools.jsapi;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.webview.jsapi.c.a;
import com.tencent.mm.plugin.webview.jsapi.e;
import com.tencent.mm.plugin.webview.jsapi.h;
import com.tencent.mm.plugin.webview.jsapi.p;
import com.tencent.mm.sdk.platformtools.ClipboardHelper;
import com.tencent.mm.sdk.platformtools.Log;
import java.util.Map;
import kotlin.Metadata;
import kotlin.a.ak;
import kotlin.g.b.s;
import kotlin.v;
@Metadata(d1={""}, d2={"Lcom/tencent/mm/plugin/webview/ui/tools/jsapi/JsApiGetPasteboardContent;", "Lcom/tencent/mm/plugin/webview/jsapi/newjsapi/BaseJsApi;", "()V", "TAG", "", "getTAG", "()Ljava/lang/String;", "controlByte", "", "getControlByte", "()I", "funcName", "getFuncName", "handleMsg", "", "env", "Lcom/tencent/mm/plugin/webview/jsapi/JsApiEnv;", "msg", "Lcom/tencent/mm/plugin/webview/jsapi/MsgWrapper;", "plugin-webview_release"}, k=1, mv={1, 5, 1}, xi=48)
public final class b
extends a
{
private static final int OOk;
private static final String TAG;
public static final b Xil;
private static final String idA;
static
{
AppMethodBeat.i(164014);
Xil = new b();
TAG = "MicroMsg.JsApiGetPasteboardContent";
OOk = 364;
idA = "getPasteboardContent";
AppMethodBeat.o(164014);
}
public final boolean a(h paramh, p paramp)
{
AppMethodBeat.i(297378);
s.u(paramh, "env");
s.u(paramp, "msg");
Object localObject = ClipboardHelper.getText(paramh.context);
Log.i(TAG, s.X("do get pasteboard content: ", localObject));
int i;
if ((localObject == null) || (((CharSequence)localObject).length() == 0))
{
i = 1;
if (i == 0) {
break label97;
}
paramh.WDy.doCallback(paramp.WEH, s.X(paramp.function, ":fail nocontent"), ak.kkZ());
}
for (;;)
{
AppMethodBeat.o(297378);
return true;
i = 0;
break;
label97:
s.s(localObject, "text");
localObject = ak.l(v.Y("content", localObject));
paramh.WDy.doCallback(paramp.WEH, s.X(paramp.function, ":ok"), (Map)localObject);
}
}
public final String gPX()
{
return idA;
}
public final int gPZ()
{
return OOk;
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes.jar
* Qualified Name: com.tencent.mm.plugin.webview.ui.tools.jsapi.b
* JD-Core Version: 0.7.0.1
*/ | [
"98632993+tsuzcx@users.noreply.github.com"
] | 98632993+tsuzcx@users.noreply.github.com |
0f1ab63cfd2567ac8b4d0ee705ae152a41ffae7b | f52981eb9dd91030872b2b99c694ca73fb2b46a8 | /Source/Plugins/Core/com.equella.core/src/com/tle/web/api/collection/interfaces/beans/CollectionSecurityBean.java | 4f8a387f23ad7219c189cb044fffaa74498ad8be | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"LGPL-2.1-only",
"LicenseRef-scancode-jdom",
"GPL-1.0-or-later",
"ICU",
"CDDL-1.0",
"LGPL-3.0-only",
"LicenseRef-scancode-other-permissive",
"CPL-1.0",
"MIT",
"GPL-2.0-only",
"Apache-2.0",
"NetCDF",
"Apache-1.1",
"EPL-1.0",
"Classpath-exception-2.... | permissive | phette23/Equella | baa41291b91d666bf169bf888ad7e9f0b0db9fdb | 56c0d63cc1701a8a53434858a79d258605834e07 | refs/heads/master | 2020-04-19T20:55:13.609264 | 2019-01-29T03:27:40 | 2019-01-29T22:31:24 | 168,427,559 | 0 | 0 | Apache-2.0 | 2019-01-30T22:49:08 | 2019-01-30T22:49:08 | null | UTF-8 | Java | false | false | 1,708 | java | /*
* Copyright 2017 Apereo
*
* 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.tle.web.api.collection.interfaces.beans;
import java.util.List;
import java.util.Map;
import com.tle.web.api.interfaces.beans.security.BaseEntitySecurityBean;
import com.tle.web.api.interfaces.beans.security.DynamicRuleBean;
import com.tle.web.api.interfaces.beans.security.TargetListEntryBean;
public class CollectionSecurityBean extends BaseEntitySecurityBean
{
private Map<String, ItemMetadataSecurityBean> metadata;
private Map<String, List<TargetListEntryBean>> statuses;
private List<DynamicRuleBean> dynamicRules;
public Map<String, ItemMetadataSecurityBean> getMetadata()
{
return metadata;
}
public void setMetadata(Map<String, ItemMetadataSecurityBean> metadata)
{
this.metadata = metadata;
}
public Map<String, List<TargetListEntryBean>> getStatuses()
{
return statuses;
}
public void setStatuses(Map<String, List<TargetListEntryBean>> statuses)
{
this.statuses = statuses;
}
public List<DynamicRuleBean> getDynamicRules()
{
return dynamicRules;
}
public void setDynamicRules(List<DynamicRuleBean> dynamicRules)
{
this.dynamicRules = dynamicRules;
}
}
| [
"doolse@gmail.com"
] | doolse@gmail.com |
a85cccf94516f58cf39d0cfbc3b4e3d6031b308f | 4d7db0996d4376b10968a6ed8ffbaa1a618ef59a | /app/src/main/java/com/cseraj/rpiteachers/TeachersActivity.java | 1355378932217085f08ad2541ac19a7d61120cb7 | [] | no_license | arifjahan88/Android_Project | 30cfb5f2d4415b84bb7ccb57680e2e6f7d0fb023 | 4050df71c39b44fab9427ea85655c1e44cd2f10c | refs/heads/master | 2023-04-16T13:27:16.510635 | 2021-04-29T13:25:32 | 2021-04-29T13:25:32 | 362,821,035 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,089 | java | package com.cseraj.rpiteachers;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class TeachersActivity extends AppCompatActivity implements View.OnClickListener{
TextView textView;
Button btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teacher);
textView = findViewById(R.id.tv);
btn1 = findViewById(R.id.cmt);
btn1.setOnClickListener(this);
btn2 = findViewById(R.id.civ);
btn2.setOnClickListener(this);
btn3 = findViewById(R.id.el);
btn3.setOnClickListener(this);
btn4 = findViewById(R.id.et);
btn4.setOnClickListener(this);
btn5 = findViewById(R.id.em);
btn5.setOnClickListener(this);
btn6 = findViewById(R.id.mn);
btn6.setOnClickListener(this);
btn7 = findViewById(R.id.mt);
btn7.setOnClickListener(this);
btn8 = findViewById(R.id.pw);
btn8.setOnClickListener(this);
btn9 = findViewById(R.id.non);
btn9.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.cmt:
Intent intent1=new Intent(TeachersActivity.this,ComputerActivity.class);
Toast.makeText(this,"This is Computer Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent1);
break;
case R.id.civ:
Intent intent2=new Intent(TeachersActivity.this,CivilActivity.class);
Toast.makeText(this,"This is Civil Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent2);
break;
case R.id.el:
Intent intent3=new Intent(TeachersActivity.this,ElectricalActivity.class);
Toast.makeText(this,"This is Electrical Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent3);
break;
case R.id.et:
Intent intent4=new Intent(TeachersActivity.this,ElectronicsActivity.class);
Toast.makeText(this,"This is Electronics Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent4);
break;
case R.id.em:
Intent intent5=new Intent(TeachersActivity.this,ElectromedicalActivity.class);
Toast.makeText(this,"This is Electromedical Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent5);
break;
case R.id.mn:
Intent intent6=new Intent(TeachersActivity.this,MechanicalActivity.class);
Toast.makeText(this,"This is Mechanical Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent6);
break;
case R.id.mt:
Intent intent7=new Intent(TeachersActivity.this,MechatronicsActivity.class);
Toast.makeText(this,"This is Mechatronics Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent7);
break;
case R.id.pw:
Intent intent8=new Intent(TeachersActivity.this,PowerActivity.class);
Toast.makeText(this,"This is Power Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent8);
break;
case R.id.non:
Intent intent9=new Intent(TeachersActivity.this,NonActivity.class);
Toast.makeText(this,"This is Non_Tech Teacher's list",Toast.LENGTH_SHORT).show();
startActivity(intent9);
break;
}
}
}
| [
"arifjahan88@gmail.com"
] | arifjahan88@gmail.com |
fb1fa2fbbe839e648a2cad4a5a30616b15702ea5 | 76c1005fd010c33ebfe0aa69020d79a846bdb1ba | /Var12/rgr/app/src/androidTest/java/com/example/rgr/ExampleInstrumentedTest.java | b67c52172ad45f5ebf24671ef5531f9bf93b8c18 | [] | no_license | misterobot404/android | 93df13c4db73e0eb2063cfa91f0842a83adef643 | 47f6fb557cf543932cbb3cd10b9e9313c90d560f | refs/heads/master | 2023-04-16T11:40:40.127179 | 2021-04-28T11:15:56 | 2021-04-28T11:15:56 | 228,775,600 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 744 | java | package com.example.rgr;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.rgr", appContext.getPackageName());
}
} | [
"misterobot404@gmail.com"
] | misterobot404@gmail.com |
11b8525907c31e13be945be8788900ecbb2ec71c | 9f1ba4c4e34e2caed1b091aeb5fc2774aed46006 | /src/ekon/simcity/city/Factory.java | a37983f743b8be9fff40d36cc175a9b6a64574d5 | [] | no_license | ekon/SimCity-BuildIt | ddd487e2675f369f36bc10c10ca3a7cba5584783 | 4a79afa25b571441669145bd2d1c25e266ac6e9b | refs/heads/master | 2021-01-02T22:30:45.880990 | 2015-07-25T03:46:35 | 2015-07-25T03:46:35 | 39,651,606 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,073 | java | package ekon.simcity.city;
import java.util.Objects;
import com.google.common.base.MoreObjects;
public class Factory extends ManufacturingFacility {
private final FactoryType type;
public Factory(FactoryType type) {
super(ManufacturingFacility.Type.FACTORY, type.getNumSlots());
this.type = type;
}
public FactoryType getFactoryType() {
return type;
}
@Override
public void addSlot() {
throw new UnsupportedOperationException("Factories cannot have slots added to them. Need to buy a new factory if want more slots.");
}
public int getNumEmptySlots() {
return 1; // TODO: implement
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.addValue(super.toString())
.add("type", type)
.toString();
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), type);
}
@Override
public boolean equals(Object other) {
if (!(other instanceof Factory)) return false;
Factory o = (Factory)other;
return super.equals(other)
&& Objects.equals(getType(), o.getType());
}
}
| [
"me@elenakon.com"
] | me@elenakon.com |
9077394ffeaf9015c8bf54116567f0b47527639a | 139960e2d7d55e71c15e6a63acb6609e142a2ace | /mobile_app1/module502/src/main/java/module502packageJava0/Foo578.java | bf639e4569ff86e1f9ce48f0ed7c70b9331a239d | [
"Apache-2.0"
] | permissive | uber-common/android-build-eval | 448bfe141b6911ad8a99268378c75217d431766f | 7723bfd0b9b1056892cef1fef02314b435b086f2 | refs/heads/master | 2023-02-18T22:25:15.121902 | 2023-02-06T19:35:34 | 2023-02-06T19:35:34 | 294,831,672 | 83 | 7 | Apache-2.0 | 2021-09-24T08:55:30 | 2020-09-11T23:27:37 | Java | UTF-8 | Java | false | false | 820 | java | package module502packageJava0;
import java.lang.Integer;
public class Foo578 {
Integer int0;
Integer int1;
Integer int2;
public void foo0() {
new module502packageJava0.Foo577().foo15();
}
public void foo1() {
foo0();
}
public void foo2() {
foo1();
}
public void foo3() {
foo2();
}
public void foo4() {
foo3();
}
public void foo5() {
foo4();
}
public void foo6() {
foo5();
}
public void foo7() {
foo6();
}
public void foo8() {
foo7();
}
public void foo9() {
foo8();
}
public void foo10() {
foo9();
}
public void foo11() {
foo10();
}
public void foo12() {
foo11();
}
public void foo13() {
foo12();
}
public void foo14() {
foo13();
}
public void foo15() {
foo14();
}
}
| [
"oliviern@uber.com"
] | oliviern@uber.com |
fe97c6c2b63d9a76a367dbe2004b83e09db272c3 | 2534632801fd1f4c59b184088c515a28078e3a70 | /src/main/java/com/nswt/service/system/fhlog/FHlogManager.java | 31981f31f1ce7aca678ad8a7c48db3fe47171315 | [] | no_license | SimonHK/ProcessIntegrationPlatform | 0b339a7051a858eedf87953471c9f8820cdd0f8b | d7bd97e3a8b125cc1137de7ede8c0498dd0f02d6 | refs/heads/master | 2021-10-27T16:07:27.150839 | 2019-04-18T10:28:45 | 2019-04-18T10:28:45 | 100,347,976 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 991 | java | package com.nswt.service.system.fhlog;
import java.util.List;
import com.nswt.entity.Page;
import com.nswt.util.PageData;
/**
* 说明: 操作日志记录接口
* 创建人:HongKai
* 创建时间:2016-05-10
* @version
*/
public interface FHlogManager{
/**新增
* @param pd
* @throws Exception
*/
public void save(String USERNAME, String CONTENT)throws Exception;
/**删除
* @param pd
* @throws Exception
*/
public void delete(PageData pd)throws Exception;
/**列表
* @param page
* @throws Exception
*/
public List<PageData> list(Page page)throws Exception;
/**列表(全部)
* @param pd
* @throws Exception
*/
public List<PageData> listAll(PageData pd)throws Exception;
/**通过id获取数据
* @param pd
* @throws Exception
*/
public PageData findById(PageData pd)throws Exception;
/**批量删除
* @param ArrayDATA_IDS
* @throws Exception
*/
public void deleteAll(String[] ArrayDATA_IDS)throws Exception;
}
| [
"18611949252@163.como"
] | 18611949252@163.como |
010c418121364a79bbf2f7cf2b0a0965b8effa08 | ac9fb6a54ac12762a4a8430b749299fe73bc4692 | /spring-in-action-5-samples-master/ch19/ingredient-client/src/main/java/tacos/ingredientclient/resttemplate/IngredientController.java | 88bb481316d6e699e66e210221cfb9452ff1f573 | [
"Apache-2.0",
"MIT"
] | permissive | PotoYang/spring-in-action-v5-translate | e16aa600dce127a7e13bf2e57ef98b8497a9cd5b | b7237abf840139ab06c46f34d309f7e3aac4499c | refs/heads/master | 2023-08-29T04:10:02.428253 | 2023-08-12T22:57:55 | 2023-08-12T22:57:55 | 199,817,598 | 1,130 | 313 | MIT | 2023-02-14T01:51:30 | 2019-07-31T08:51:23 | Java | UTF-8 | Java | false | false | 1,220 | java | package tacos.ingredientclient.resttemplate;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.extern.slf4j.Slf4j;
@Controller
@RequestMapping("/ingredients")
@Conditional(NotFeignAndNotWebClientCondition.class)
@Slf4j
public class IngredientController {
private IngredientServiceClient client;
public IngredientController(IngredientServiceClient client) {
this.client = client;
}
@GetMapping
public String showAllIngredients(Model model) {
log.info("Fetched all ingredients from a RestTemplate-based service.");
model.addAttribute("ingredients", client.getAllIngredients());
return "ingredientList";
}
@GetMapping("/{id}")
public String getIngredientById(@PathVariable("id") String id, Model model) {
log.info("Fetched an ingredient from a RestTemplate-based service.");
model.addAttribute("ingredient", client.getIngredientById(id));
return "ingredientDetail";
}
}
| [
"715792648@qq.com"
] | 715792648@qq.com |
5e51fd2ebacc8107cd883df99966e2546e8145c5 | 50586c505c1cdd6ad77bc27bd2da900bdda21d30 | /src/test/java/objects/asv/journal/AsvJournal.java | f79f36f626d32ce18adeac27dc80eaff569410fc | [] | no_license | evilnoob/soop-auto-test | daf1764d3d9c93eb61d364b09116b56d669698b7 | 86753bfa76e785f7fb34141af5ff1d39cded79be | refs/heads/master | 2021-01-10T18:10:57.429041 | 2016-10-06T12:19:23 | 2016-10-06T12:19:23 | 69,655,174 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,666 | java | package objects.asv.journal;
import elements.Button;
import elements.CheckBox;
import elements.ElementsGrid;
import elements.RadioButton;
import objects.Page;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import ru.yandex.qatools.allure.annotations.Step;
import java.util.List;
public class AsvJournal extends Page {
public AsvJournal(WebDriver driver) {
super(driver);
}
//public List<WebElement> caseList = ElementsGrid.elementsSearchGridFromJournal(driver, "Журнал административного производства");
public List<WebElement> caseList;
public WebElement physicalRadio = RadioButton.radioButtonFromContainer(driver, "Тип нарушителя", "Физ. лицо");
public WebElement juridicalRadio = RadioButton.radioButtonFromContainer(driver, "Тип нарушителя", "Юр. лицо");
public WebElement currentCheckbox = CheckBox.checkBoxFromBlock(driver, "Редактировать", "Свой тер. орган");
public WebElement subordinateCheckbox = CheckBox.checkBoxFromBlock(driver, "Редактировать", "Нижестоящие тер. органы");
public WebElement editButton = Button.button(driver, "Редактировать");
public WebElement downloadButton = Button.button(driver, "Выгрузить");
public WebElement journalCloseButton = Button.button(driver, "Завершить работу с журналом");
public WebElement columnsVisibilityButton = Button.buttonWithDataQtip(driver, "Видимость столбцов");
@Step("Нажатие радиобаттона \"Физ. лицо\".")
public void physicalRadioClick() throws InterruptedException {
physicalRadio.click();
}
@Step("Нажатие радиобаттона \"Юр. лицо\".")
public void juridicalRadioClick() throws InterruptedException {
juridicalRadio.click();
}
@Step("Нажатие чекбокса \"Свой тер. орган\".")
public void currentCheckboxClick() throws InterruptedException {
currentCheckbox.click();
}
@Step("Нажатие чекбокса \"Нижестоящие тер. органы\".")
public void subordinateCheckboxClick() throws InterruptedException {
subordinateCheckbox.click();
}
@Step("Нажатие кнопки \"Редактировать\".")
public void editButtonClick(){
editButton.click();
}
@Step("Нажатие кнопки \"Выгрузить\".")
public void downloadButtonClick(){
downloadButton.click();
}
@Step("Нажатие кнопки \"Завершить работу с журналом\".")
public void journalCloseButtonClick(){
journalCloseButton.click();
}
public void selectIfPresent(){
caseList = ElementsGrid.elementsSearchGridFromJournal(driver, "Журнал административного производства");
//System.out.println(caseList.toString());
//System.out.println(caseList.get(0).toString());
//System.out.println(caseList.get(0).getText());
//System.out.println("id "+caseList.get(0).getAttribute("id"));
//System.out.println("value "+caseList.get(0).getAttribute("value"));
if (!caseList.isEmpty()){
System.out.println(caseList.get(0).getAttribute("id"));
caseList.get(0).click();
}
}
@Step("Нажатие кнопки \"Видимость столбцов\".")
public void columnsVisibilityClick(){
columnsVisibilityButton.click();
}
}
| [
"akhudoleev@at-consulting.ru"
] | akhudoleev@at-consulting.ru |
a5b17a13378e0841d454319f0c51f3fe29b60be3 | bafab6aea4107c2915cc2da62fa14296f4f9ded9 | /kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-widgets/src/main/java/org/kie/workbench/common/stunner/client/widgets/canvas/FocusableLienzoPanelView.java | 3105f363402db7f12b408838c756fcd6e071623d | [
"Apache-2.0"
] | permissive | lazarotti/kie-wb-common | 7da98f53758c211c94002660cf44698b9a2cccc4 | bc98aca29846baaa01fb9a5dc468ab4f3f55a8c7 | refs/heads/master | 2021-01-12T01:46:55.935051 | 2017-01-09T10:58:05 | 2017-01-09T10:58:05 | 78,430,514 | 0 | 0 | null | 2017-01-09T13:19:14 | 2017-01-09T13:19:14 | null | UTF-8 | Java | false | false | 2,111 | java | /*
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.kie.workbench.common.stunner.client.widgets.canvas;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* LienzoPanel that can take the Focus (and more importantly cause other Widgets to loose the Focus)
*/
public class FocusableLienzoPanelView extends com.ait.lienzo.client.widget.LienzoPanel {
public FocusableLienzoPanelView( final int width,
final int height ) {
super( width,
height );
//Basic support to loose focus on other Widgets when a WiresCanvas is clicked
addMouseDownHandler( new MouseDownHandler() {
@Override
public void onMouseDown( final MouseDownEvent event ) {
broadcastBlurEvent();
}
} );
addMouseWheelHandler( new MouseWheelHandler() {
@Override
public void onMouseWheel( final MouseWheelEvent event ) {
broadcastBlurEvent();
}
} );
}
protected void broadcastBlurEvent() {
final NativeEvent blur = Document.get().createBlurEvent();
for ( int i = 0; i < RootPanel.get().getWidgetCount(); i++ ) {
final Widget w = RootPanel.get().getWidget( i );
DomEvent.fireNativeEvent( blur,
w );
}
}
}
| [
"manstis@users.noreply.github.com"
] | manstis@users.noreply.github.com |
54c6b63e75e17ef9c1f7e5dbef8a6fd30a12b8aa | ffa7a4d37f92896fedbb348993307b43da8858ba | /src/main/java/am/globbing/pages/blog/BlogPageXpaths.java | 4158ae054207c2e2497263a61eacbe01a92a0de2 | [] | no_license | SandroDarbinyan/GlobbingPageObject | 01d7bb319fd89d316a16dd627dd296c21a3fbfe7 | af138aa2a79f386f9a98794ddf7ad38ed50459f4 | refs/heads/master | 2023-05-12T17:54:18.570808 | 2020-01-10T12:20:21 | 2020-01-10T12:20:21 | 233,038,944 | 0 | 1 | null | 2023-05-09T18:37:10 | 2020-01-10T12:05:33 | Java | UTF-8 | Java | false | false | 151 | java | package am.globbing.pages.blog;
public class BlogPageXpaths {
public static final String BLOG_LOGO = "//header[@class='dark']/div[1]/a/img[2]";
}
| [
"sandro.darbinyayn@gmail.com"
] | sandro.darbinyayn@gmail.com |
ef68124032560faa130d9338ae4203a3c7016d13 | a1826c2ed9c12cfc395fb1a14c1a2e1f097155cb | /green-20180509/src/main/java/com/aliyun/green20180509/models/ImageSyncScanResponse.java | 8d77d73d96a588c56f9db34012284e5942cecdb2 | [
"Apache-2.0"
] | permissive | aliyun/alibabacloud-java-sdk | 83a6036a33c7278bca6f1bafccb0180940d58b0b | 008923f156adf2e4f4785a0419f60640273854ec | refs/heads/master | 2023-09-01T04:10:33.640756 | 2023-09-01T02:40:45 | 2023-09-01T02:40:45 | 288,968,318 | 40 | 45 | null | 2023-06-13T02:47:13 | 2020-08-20T09:51:08 | Java | UTF-8 | Java | false | false | 735 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.green20180509.models;
import com.aliyun.tea.*;
public class ImageSyncScanResponse extends TeaModel {
@NameInMap("headers")
@Validation(required = true)
public java.util.Map<String, String> headers;
public static ImageSyncScanResponse build(java.util.Map<String, ?> map) throws Exception {
ImageSyncScanResponse self = new ImageSyncScanResponse();
return TeaModel.build(map, self);
}
public ImageSyncScanResponse setHeaders(java.util.Map<String, String> headers) {
this.headers = headers;
return this;
}
public java.util.Map<String, String> getHeaders() {
return this.headers;
}
}
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
c1844236d1c9e60ca893a9959da78642dc9dff72 | 1a99e9f8b78495ebaef5420f4f3b0dc5c24b85ab | /User Profile/src/sample/successPassMatchBox.java | ddd6e4b288310ca93bae0e98d11647e91fba7cab | [
"MIT"
] | permissive | ferdouszislam/CSE215-Project | c5b4c9582360ba7ced2bacf3ea83af646127d40b | 4c402c7bc917df01845c128960f387fe7b57ee6c | refs/heads/master | 2020-03-28T02:42:26.192621 | 2018-09-05T20:42:22 | 2018-09-05T20:42:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 952 | java | package sample;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class successPassMatchBox {
public static void showBox() {
try {
FXMLLoader alertbox = new FXMLLoader(successPassMatchBox.class.getResource("successPassMatchBox.fxml"));
Stage abStage = new Stage();
AnchorPane pane = alertbox.load();
Scene scene = new Scene(pane);
abStage.setScene(scene);
abStage.setResizable(false);
abStage.setTitle("SUCCESS!");
abStage.setAlwaysOnTop(true);
abStage.initModality(Modality.APPLICATION_MODAL);
abStage.getIcons().add(new Image(successPassMatchBox.class.getResourceAsStream("success.png")));
abStage.show();
} catch (Exception e) {
}
}
}
| [
"rifatislamomio@gmail.com"
] | rifatislamomio@gmail.com |
238b62e625b9e58349040c5fe6a02497efc6ccae | 3ca1c02b6b13b5f79658db5c08b6b1e47e20b2d4 | /app/src/main/java/com/company/workpeace/ClasesPrincipales/EditarMyDoes.java | e336a0559373f21746b97d8a15ae827507ebf8e4 | [] | no_license | Jfvp0412/Ingesoft2.0 | 24ce41e75efc5bd885e62984ba8f79dce1c6e13d | 70552134a6872dd138dca7288b1a3848bb5373d0 | refs/heads/master | 2023-01-15T10:55:02.155082 | 2020-11-26T16:57:00 | 2020-11-26T16:57:00 | 316,286,605 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,273 | java | package com.company.workpeace.ClasesPrincipales;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import com.company.workpeace.ClasesAuxiliares.Firebase.DatePickerFragment;
import com.company.workpeace.ClasesAuxiliares.Firebase.MyDoesAux;
import com.company.workpeace.R;
import com.company.workpeace.Reciclador.DoesAdapter;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class EditarMyDoes extends AppCompatActivity implements DatePickerDialog.OnDateSetListener {
EditText titulo, desc, fecha, editarHora;
TextView editarFecha;
Button btnEditarTask, btnEliminar, btnEditarCalendario, btnAbrirReloj;
DatabaseReference reference;
int t1Hour, t1Minute,t2Hour, t2Minute;
String usuario;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_editar_my_does);
Intent intent = getIntent();
titulo = findViewById(R.id.editarTitulo);
desc = findViewById(R.id.editarDesc);
fecha = findViewById(R.id.editarFecha);
editarHora = findViewById(R.id.editarHoras);
editarFecha = findViewById(R.id.adddate);
btnEditarTask = findViewById(R.id.btnSaveUpdate);
btnEliminar = findViewById(R.id.btnDelete);
btnEditarCalendario = findViewById(R.id.btneditarCalendario);
btnAbrirReloj = findViewById(R.id.btneditarHora);
btnAbrirReloj.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TimePickerDialog timePickerDialog = new TimePickerDialog(EditarMyDoes.this, android.R.style.Theme_Holo_Dialog_MinWidth, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
t2Hour = hourOfDay;
t2Minute = minute;
String time = t2Hour + ":" + t2Minute;
SimpleDateFormat f24Hours = new SimpleDateFormat("HH:mm");
try {
Date date = f24Hours.parse(time);
SimpleDateFormat f12Hours = new SimpleDateFormat("hh:mm aa");
editarHora.setText(f12Hours.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
}
},12,0,false
);
timePickerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
timePickerDialog.updateTime(t2Hour,t2Minute);
timePickerDialog.show();
}
});
btnEditarCalendario.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment datePicker = new DatePickerFragment();
datePicker.show(getSupportFragmentManager(),"date picker");
}
});
titulo.setText(getIntent().getStringExtra("titledoes"));
desc.setText(getIntent().getStringExtra("descdoes"));
fecha.setText(getIntent().getStringExtra("datedoes"));
editarHora.setText(getIntent().getStringExtra("getHora"));
final String keykeydoes = getIntent().getStringExtra("keydoes");
final String usuario = getIntent().getStringExtra("username");
//Toast.makeText(EditarMyDoes.this,":"+usuario,Toast.LENGTH_LONG).show();
btnEditarTask.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reference = FirebaseDatabase.getInstance().getReference().child("DoesApp").child(usuario);
//Toast.makeText(EditarMyDoes.this,":"+usuario,Toast.LENGTH_SHORT).show();
reference.child("Does" + keykeydoes).child("titulo").setValue(titulo.getText().toString());
reference.child("Does" + keykeydoes).child("descripcion").setValue(desc.getText().toString());
reference.child("Does" + keykeydoes).child("fecha").setValue(fecha.getText().toString());
reference.child("Does" + keykeydoes).child("hora").setValue(editarHora.getText().toString());
reference.child("Does" + keykeydoes).child("keydoes").setValue(keykeydoes);
reference.child("Does" + keykeydoes).child("usuario").setValue(usuario);
Intent a = new Intent(EditarMyDoes.this,MyDoes.class);
a.putExtra("usuario",usuario);
Toast.makeText(EditarMyDoes.this,"Cambios guardados...",Toast.LENGTH_LONG).show();
startActivity(a);
}
});
btnEliminar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reference = FirebaseDatabase.getInstance().getReference().child("DoesApp").child(usuario).child("Does" + keykeydoes);
reference.removeValue().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Intent a = new Intent(EditarMyDoes.this,MyDoes.class);
a.putExtra("usuario",usuario);
Toast.makeText(EditarMyDoes.this,"Recordatorio eliminado...",Toast.LENGTH_LONG).show();
startActivity(a);
}
else{
Toast.makeText(EditarMyDoes.this,"No se pudo eliminar...",Toast.LENGTH_LONG).show();
}
}
});
}
});
}
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
String currentDateString = DateFormat.getDateInstance().format(c.getTime());
fecha.setText(currentDateString);
}
} | [
"j_vanegas@javeriana.edu.co"
] | j_vanegas@javeriana.edu.co |
db0ed0905787da2d82f87ebd63f8339a3277692c | db981d2df36f5585edddea51caa0a4818d29a6b1 | /Futzinho/src/futzinho/AuxilioJogo.java | bbb482c1d57eb28fcca15e513690394ee6719279 | [
"MIT"
] | permissive | Vitor-Manoel1014/Futsal-Simulacao-Jogos | 708c39a10ea2cf6ff85e967b0331b7f6c46b793b | 97b2f0023a602481babaf8b59b05928f95558c4c | refs/heads/master | 2022-04-18T11:32:29.440012 | 2020-04-19T01:24:19 | 2020-04-19T01:24:19 | 256,888,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,972 | java | package futzinho;
import javax.swing.JOptionPane;
public class AuxilioJogo {
public int ataque(Atacante ata, Goleiro gol, Atacante zag, int g) {
double a;
int go = 0;
a = Math.round(1 + Math.random() * (20 - 1));
if (a == 1) {//JOGADA HISTÓRICA
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " dribla o time adversário inteiro");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " dribla um");
JOptionPane.showMessageDialog(null, ata.getNome() + " dribla dois");
JOptionPane.showMessageDialog(null, ata.getNome() + " dribla três");
JOptionPane.showMessageDialog(null, ata.getNome() + " dribla quatro");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " mete um chutaço no ângulo lá da defesa");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " desafia " + gol.getNome() + " com um chute de trivela a 130km por hora");
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " deixa " + zag.getNome() + " no chão junto com a defesa adversária");
}
while (go == 0) {
a = Math.round(1 + Math.random() * (50 - 1));
if (a > 10 && a <= (ata.getChute() + 50)) {//FAZ O GOL HISTÓRICO
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, MEU DEUS DO CÉU QUE GOLAÇO");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLLAAAAAAAÇÇOOOOOOOOO, O GOL DA VIDA DELE");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL ");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, "GOOOLLLLL, ELE BRINCOU COM O TIME ADVERSÁRIO");
} else {
JOptionPane.showMessageDialog(null, "OLHA O GOL, OLHA O GOL, OLHA O GOL, OLHA O GOL, NEM PELÉ FARIA");
}
JOptionPane.showMessageDialog(null, ata.getComemoracao());
go = 1;
} else if (a < gol.getDefesaPerto()) {// GOLEIRO FAZ DEFESA HISTTÓRICA
JOptionPane.showMessageDialog(null, gol.getNome() + " INCRIVELMENTE DEFENDE, É A DEFESA DA SUA VIDA");
go = 2;
}
}
if (go == 1) {
g = 1;
}
} else if (a == 2 || a == 3 || a == 4) {//CHUTE DE LONGE
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " arrisca do meio da quadra");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " tenta surpreender " + gol.getNome() + " de longe");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " mete uma sapatada de longe");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " desafia " + gol.getNome() + " com um chute de longe");
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " não quer nem saber e chuta de longe no gol de " + gol.getNome());
}
while (go == 0) {
a = Math.round(1 + Math.random() * (30 - 1));
if (a <= ata.getChute()) {//FAZ O GOL DE LONGE
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLLAAAAAAAÇÇOOOOOOOOO DO MEIO DA RUA");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL LINDO DE LONGE");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, "GOOOLLLLL, SUPREENDENDO O GOLEIRO");
} else {
JOptionPane.showMessageDialog(null, "OLHA O GOL, OLHA O GOL, OLHA O GOL, OLHA O GOL");
}
JOptionPane.showMessageDialog(null, ata.getComemoracao());
go = 1;
} else if (a > 10 && a <= (gol.getDefesa() + 20)) {//GOLEIRO DEFENDE DE LONGE
JOptionPane.showMessageDialog(null, gol.getDefLonge());
go = 2;
}
}
if (go == 1) {
g = 1;
}
} else if (a == 5 || a == 6 || a == 7) {//CHUTE MÉDIA DISTANCIA
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " chuta de meia distância");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " tenta o chute em " + gol.getNome() + " de longe");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " mete uma sapatada");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " desafia " + gol.getNome() + " com um chute");
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " não quer nem saber e chuta no meio de todo mundo no gol de " + gol.getNome());
}
while (go == 0) {
a = Math.round(1 + Math.random() * (20 - 1));
if (a <= ata.getChute()) {//FAZ O GOL DE MÉDIA DISTÂNCIA
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLLAAAAAAAÇÇOOOOOOOOO");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL LINDO");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, "GOOOLLLLL, UM FRANGO DO GOLEIRO");
} else {
JOptionPane.showMessageDialog(null, "OLHA O GOL, OLHA O GOL, OLHA O GOL, OLHA O GOL");
}
JOptionPane.showMessageDialog(null, ata.getComemoracao2());
go = 1;
} else if (a > 10 && a <= (gol.getDefesa() + 10)) {//GOLEIRO DEFENDE DE MÉDIA DISTÂNCIA
JOptionPane.showMessageDialog(null, gol.getDefMedio());
go = 2;
}
}
if (go == 1) {
g = 1;
}
} else if (a == 8 || a == 9 || a == 10) {//CHUTE QUEIMA ROUPA
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " chuta de perto");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " tenta o chute em " + gol.getNome() + " de um angulo improvavel");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " mete uma sapatada a queima roupa");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " desafia " + gol.getNome() + " com um chute queima roupa");
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " não quer nem saber e tenta driblar " + gol.getNome());
}
while (go == 0) {
a = Math.round(1 + Math.random() * (30 - 1));
if (a > 10 && a <= (ata.getChute() + 20)) {//FAZ O GOL DE CURTA DISTÂNCIA
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, SEM CHANCES PRO GOLEIRO");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLLAAAAAAAÇÇOOOOOOOOO, O GOLEIRO NEM VIU A BOLA");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, BELO POSICIONAMENTO DE ATAQUE");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, "GOOOLLLLL, UM FRANGO DO GOLEIRO, QUE SAI ERRADO");
} else {
JOptionPane.showMessageDialog(null, "OLHA O GOL, OLHA O GOL, OLHA O GOL, OLHA O GOL, SEM NENHUMA CHANCE PRO GOLEIRO");
}
JOptionPane.showMessageDialog(null, ata.getComemoracao2());
go = 1;
} else if (a <= gol.getDefesaPerto()) {//GOLEIRO DEFENDE DE CURTA DISTÂNCIA
JOptionPane.showMessageDialog(null, gol.getDefPerto());
go = 2;
}
}
if (go == 1) {
g = 1;
}
} else if (a == 11 || a == 12) {//PENÂLTI
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, "É PENAAAALTI");
JOptionPane.showMessageDialog(null, zag.getNome() + " pega a bola com a mão dentro da area");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " toma um carrinho criminoso de " + gol.getNome() + " e é penalti");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " é derrubado por " + zag.getNome() + " dentro da aréa");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, "PENALIDADE MÁXIMA MARCADA");
JOptionPane.showMessageDialog(null, ata.getNome() + " é atropelado por " + zag.getNome() + " dentro da aréa");
} else {
JOptionPane.showMessageDialog(null, "PENAAAALTI");
JOptionPane.showMessageDialog(null, ata.getNome() + " tenta o drible e é puxado por " + gol.getNome());
}
while (go == 0) {
a = Math.round(1 + Math.random() * (30 - 1));
if (a > 10 && a <= (ata.getPenalti() + 20)) {//FAZ O GOL DE PENALTI
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na direita");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, SEM CHANCES PRO GOLEIRO");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na esquerda");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, O GOLEIRO NEM VIU A BOLA");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " ri de " + gol.getNome() + " antes de chutar");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " parece nervoso antes de bater");
JOptionPane.showMessageDialog(null, "GOOOLLLLL, UM FRANGO DO GOLEIRO, A BOLA PASSA NO MEIO DAS MÃOS DELE");
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " toma uma água antes de bater o penalti");
JOptionPane.showMessageDialog(null, "OLHA O GOL, OLHA O GOL, OLHA O GOL, OLHA O GOL, SEM NENHUMA CHANCE PRO GOLEIRO");
}
JOptionPane.showMessageDialog(null, ata.getComemoracao2());
go = 1;
} else if (a <= gol.getDefesaPenalti()) {//GOLEIRO DEFENDE O PENALTI
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na direita");
JOptionPane.showMessageDialog(null, gol.getDefPenal());
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na esquerda");
JOptionPane.showMessageDialog(null, gol.getDefPenal());
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " ri de " + gol.getNome() + " antes de chutar");
JOptionPane.showMessageDialog(null, gol.getDefPenal());
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " parece nervoso antes de bater");
JOptionPane.showMessageDialog(null, gol.getDefPenal());
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " toma uma água antes de bater o penalti");
JOptionPane.showMessageDialog(null, gol.getDefPenal());
}
go = 2;
}
}
if (go == 1) {
g = 1;
}
} else if (a == 13 || a == 14) {//FALTA DE LONGE
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, "é falta, mas parece bem longe");
JOptionPane.showMessageDialog(null, zag.getNome() + " pega a bola com a mão sem querer");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " toma um carrinho criminoso de " + zag.getNome() + " no meio da quadra e é falta");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " é derrubado por " + zag.getNome() + " e é falta, mas parece bem longe para chutar");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, "Falta marcada no meioo da quadra");
JOptionPane.showMessageDialog(null, ata.getNome() + " é atropelado por " + zag.getNome());
} else {
JOptionPane.showMessageDialog(null, "Falta marcada, mas parece longe para chutar");
JOptionPane.showMessageDialog(null, ata.getNome() + " tenta o drible e é puxado por " + zag.getNome());
}
while (go == 0) {
a = Math.round(1 + Math.random() * (30 - 1));
if (a <= ata.getChute()) {//FAZ O GOL DE FALTA DE LONGE
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar no gol");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, SEM CHANCES PRO GOLEIRO, NO ÂNGULO");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz que irá apenas cruzar");
JOptionPane.showMessageDialog(null, ata.getNome() + " decide chutar de última hora");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, O GOLEIRO NEM VIU A BOLA DE TÃO RÁPIDA");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " ri de " + gol.getNome() + " antes de cobrar a falta");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLLAAAAAAAAÇOOOO DO MEIO DA QUADRA");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " parece nervoso antes de bater, será que ele irá bater direto");
JOptionPane.showMessageDialog(null, ata.getNome() + " chuta no gol");
JOptionPane.showMessageDialog(null, "GOOOLLLLL, UM FRANGO DO GOLEIRO, A BOLA PASSA DIRETO PELAS MÃOS DELE");
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " não quer saber e vai chutar do meio da quadra");
JOptionPane.showMessageDialog(null, "OLHA O GOL, OLHA O GOL, OLHA O GOL, OLHA O GOL, SEM NENHUMA CHANCE PRO GOLEIRO QUE FICA PARADO NO MEIO DO GOL");
}
JOptionPane.showMessageDialog(null, ata.getComemoracao());
go = 1;
} else if (a > 10 && a <= (gol.getDefesa() + 20)) {//GOLEIRO DEFENDE A FALTA DE LONGE
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar no gol");
JOptionPane.showMessageDialog(null, gol.getDefLonge());
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz que irá apenas cruzar");
JOptionPane.showMessageDialog(null, ata.getNome() + " decide chutar de última hora");
JOptionPane.showMessageDialog(null, gol.getDefLonge());
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " ri de " + gol.getNome() + " antes de cobrar a falta");
JOptionPane.showMessageDialog(null, gol.getDefLonge());
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " parece nervoso antes de bater, será que ele irá bater direto");
JOptionPane.showMessageDialog(null, ata.getNome() + " chuta no gol");
JOptionPane.showMessageDialog(null, gol.getDefLonge());
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " não quer saber e vai chutar do meio da quadra");
JOptionPane.showMessageDialog(null, gol.getDefLonge());
}
go = 2;
}
}
if (go == 1) {
g = 1;
} else if (a == 15 || a == 16) {//FALTA DE PERTO
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, "É FALTA, PERTO DA AREA");
JOptionPane.showMessageDialog(null, zag.getNome() + " pega a bola com a mão perto da area");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " toma um carrinho criminoso de " + gol.getNome() + " e é falta, quase penalti");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " é derrubado por " + zag.getNome() + " perto da aréa");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, "FALTA, DO LADO ESQUERDO DA AREA");
JOptionPane.showMessageDialog(null, ata.getNome() + " é atropelado por " + zag.getNome() + " perto da aréa");
} else {
JOptionPane.showMessageDialog(null, "FALTA MARCADA");
JOptionPane.showMessageDialog(null, ata.getNome() + " tenta o drible e é puxado por " + gol.getNome());
}
while (go == 0) {
a = Math.round(1 + Math.random() * (25 - 1));
if (a > 10 && a <= (ata.getPenalti() + 15)) {//FAZ O GOL DE FALTA
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na direita");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, SEM CHANCES PRO GOLEIRO");
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na esquerda");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL, O GOLEIRO NEM VIU A BOLA");
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " ri de " + gol.getNome() + " antes de chutar");
JOptionPane.showMessageDialog(null, "GOOOOOOOOOOLLLLLLLLLL");
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " parece nervoso antes de bater");
JOptionPane.showMessageDialog(null, "GOOOLLLLL, UM FRANGO DO GOLEIRO, A BOLA PASSA NO MEIO DAS MÃOS DELE");
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " toma uma água antes de bater o penalti");
JOptionPane.showMessageDialog(null, "OLHA O GOL, OLHA O GOL, OLHA O GOL, OLHA O GOL, SEM NENHUMA CHANCE PRO GOLEIRO");
}
JOptionPane.showMessageDialog(null, ata.getComemoracao());
go = 1;
} else if (a <= gol.getDefesaPenalti()) {//GOLEIRO DEFENDE A FALTA DE PERTO
a = Math.round(1 + Math.random() * (5 - 1));
if (a == 1) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na direita");
JOptionPane.showMessageDialog(null, gol.getDefPerto());
} else if (a == 2) {
JOptionPane.showMessageDialog(null, ata.getNome() + " faz menção que irá chutar na esquerda");
JOptionPane.showMessageDialog(null, gol.getDefPerto());
} else if (a == 3) {
JOptionPane.showMessageDialog(null, ata.getNome() + " ri de " + gol.getNome() + " antes de chutar");
JOptionPane.showMessageDialog(null, gol.getDefPerto());
} else if (a == 4) {
JOptionPane.showMessageDialog(null, ata.getNome() + " parece nervoso antes de bater");
JOptionPane.showMessageDialog(null, gol.getDefPerto());
} else {
JOptionPane.showMessageDialog(null, ata.getNome() + " toma uma água antes de bater o penalti");
JOptionPane.showMessageDialog(null, gol.getDefPerto());
}
go = 2;
}
}
if (go == 1) {
g = 1;
}
} else if (a == 17 || a == 18 || a == 19 || a == 20) {//ERRO DE PASSE
if (a == 17 || a == 18) {
JOptionPane.showMessageDialog(null, ata.getErroP());
} else {
JOptionPane.showMessageDialog(null, ata.getErroP2());
}
}
}
return g;
}
}
| [
"vm53596@gmail.com"
] | vm53596@gmail.com |
8ddb330667b5f0e0608d37283f5a24083a4e91a8 | 31f428938ecddcf59582e77d6a3739d591978d2e | /app/src/test/java/com/example/user/favouritealbums/FavoriteAlbumsTest.java | 61965eab8e1ac788123036b6fba8e6720599b614 | [] | no_license | underscoredotspace/cc-homework-android-album-list | d3fff876199400babe2d40ee97a13561c68d7768 | 0fa4f4915abd376b0e5582522838b75a4e00f6ff | refs/heads/master | 2020-03-19T00:26:31.767121 | 2018-05-30T18:16:44 | 2018-05-30T18:16:44 | 135,481,146 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 525 | java | package com.example.user.favouritealbums;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class FavoriteAlbumsTest {
FavoriteAlbums albums;
@Before
public void before() {
albums = new FavoriteAlbums();
}
@Test
public void getList() {
assertEquals(2, albums.getList().size());
}
@Test
public void addAlbum() {
albums.addAlbum("Prince", "Purple Rain", 1983, 1);
assertEquals(3, albums.getList().size());
}
} | [
"ampersand@underscore.space"
] | ampersand@underscore.space |
f22a5c6da32d6d2b594b1f8ea4753f5a446755c8 | 1ac1f3e678bc6694a69e9f886c89cf981a670ba6 | /app/src/main/java/com/example/iyou/route/activity/RouteListAdapter.java | f39c1d4184c3f01ffb10a3ef5c4ba25f0c04fd01 | [] | no_license | huanglu20124/Iyou | 807ce4cd3db1efbc070d232a42ef3d375a0854f5 | 6e8b2a6b0a26bd1843f7a14217aa7fd099c80b46 | refs/heads/master | 2021-01-01T04:37:27.501254 | 2017-07-14T08:17:52 | 2017-07-14T08:17:52 | 97,211,304 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,504 | java | package com.example.iyou.route.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.TextView;
import com.avos.avoscloud.AVUser;
import com.example.iyou.R;
import com.example.iyou.model.utils.DAOFactory;
import com.example.iyou.model.utils.FileUtils;
import com.example.iyou.tool.CustomImageView;
import java.util.List;
import java.util.Map;
/**
* Created by asus on 2017/1/4.
* 作为自定义路线列表显示的listview的适配器
*/
public class RouteListAdapter extends BaseAdapter {
// private List<Map<String, Object>> data;
private List<Object> data;
private LayoutInflater layoutInflater;
private Context context;
public RouteListAdapter(Context context, List<Object> data) {
this.context = context;
this.data = data;
this.layoutInflater = LayoutInflater.from(context);
}
public final class ViewHolder{
TextView routeName;
ImageButton editBtn;
ImageButton shareBtn;
ImageButton deleteBtn;
CustomImageView routOneImage;
TextView listNumFlag;
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return data.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewholder=null;
if(convertView==null){
viewholder=new ViewHolder();
convertView = layoutInflater.inflate(R.layout.route_list_item, null);
viewholder.routeName=(TextView)convertView.findViewById(R.id.route_name);
viewholder.editBtn=(ImageButton)convertView.findViewById(R.id.route_edit);
viewholder.editBtn.setTag(position);
viewholder.shareBtn=(ImageButton)convertView.findViewById(R.id.route_share);
viewholder.shareBtn.setTag(position);
viewholder.deleteBtn=(ImageButton)convertView.findViewById(R.id.route_delete);
viewholder.routOneImage = (CustomImageView) convertView.findViewById(R.id.routeOneImage);
viewholder.routOneImage.setTag(position);
viewholder.listNumFlag = (TextView) convertView.findViewById(R.id.listNumFlag);
viewholder.listNumFlag.setTag(position);
convertView.setTag(viewholder);
}
else {
viewholder = (ViewHolder) convertView.getTag();
}
//获取路线连线的各个名字连成串再赋值给控件
List<Map<String,Object>> listdata=null;
listdata= (List<Map<String, Object>>) data.get(position);
StringBuffer routeName = new StringBuffer();
for(Map map:listdata){
routeName.append(map.get("sceneryName") + "->");
}
viewholder.routeName.setText((String) routeName.toString().substring(0,routeName.toString().length()-2));
viewholder.routOneImage.setImageUrl((String) listdata.get(0).get("sceneryImageUrl"));
viewholder.listNumFlag.setText("路线 "+String.valueOf(position+1));
// viewholder.routeName.setText((String) data.get(position).get("route"));
//设置删除按钮事件
viewholder.deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AlertDialog.Builder(context)
.setTitle("注意")
.setMessage("你确定要删除你的路线吗?")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
data.remove(position);
//上传路线到服务器
AVUser.getCurrentUser().put("Routes",data);
AVUser.getCurrentUser().saveInBackground();
// //保存我的路线在本地,位置在storage-emulated-0-MyRoute.txt文件里面
// FileUtils fileUtils=new FileUtils();
// //如果数据集是空的话,直接删除文件
// if(data.size()==0){
// fileUtils.deleteFile(fileUtils.getSDPATH()+"MyRoute.txt");
// }
// //删除文件后就更新覆盖文件内容
// for(int i=0;i<data.size();i++){
// //第一个条内容是覆盖文件
// if(i==0)
// fileUtils.save(data.get(i),fileUtils.getSDPATH()+"MyRoute.txt",false);
// else
// fileUtils.save(data.get(i),fileUtils.getSDPATH()+"MyRoute.txt",true);
// }
RouteListAdapter.this.notifyDataSetChanged();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.show();
}
});
//设置分享按钮事件
viewholder.shareBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DAOFactory.getRouteServiceInstance().toEidtShareRoutePage((Activity) context, data, (Integer) v.getTag());
}
});
//设置修改按钮事件
viewholder.editBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DAOFactory.getRouteServiceInstance().toEditRoutePage((Activity) context, data, (Integer) v.getTag());
}
});
return convertView;
}
} | [
"845758437@qq.com"
] | 845758437@qq.com |
903a91cd6b4e37d659f3a354d3daaba81d145099 | ca9a2351373eb4f3753d63eb5073f2dd6fc71b0b | /addressbook-web-tests/src/test/java/ru/stqa/pft/addressbook/tests/GroupModificationTests.java | e1ddab8bd11cd3d5fa24857ec541a85a32748cb1 | [
"Apache-2.0"
] | permissive | InessaMakarchuk/java_pft | 3370240e6ccd453a0e8812ecbbe0f69538bb8263 | 33d104f87825e4b4a2a7cd1324efef40b312ccfb | refs/heads/master | 2020-06-09T06:04:00.879132 | 2019-08-29T23:38:30 | 2019-08-29T23:38:30 | 193,360,007 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,123 | java | package ru.stqa.pft.addressbook.tests;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.GroupData;
import ru.stqa.pft.addressbook.model.Groups;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
public class GroupModificationTests extends TestBase {
@BeforeMethod
public void ensurePreconditions() {
if (app.db().groups().size() == 0) {
app.goTo().groupPage();
app.group().create(new GroupData().withName("TestGroup"));
}
}
@Test
public void testGroupModification() {
Groups before = app.db().groups();
GroupData modifiedGroup = before.iterator().next();
GroupData group = new GroupData()
.withId(modifiedGroup.getId()).withName("123").withHeader("234").withFooter("345");
app.goTo().groupPage();
app.group().modify(group);
assertThat(app.group().count(), equalTo(before.size()));
Groups after = app.db().groups();
assertThat(after, equalTo(before.without(modifiedGroup).withAdded(group)));
verifyGroupListInUI();
}
}
| [
"inessa.makarchuk@gmail.com"
] | inessa.makarchuk@gmail.com |
37421a0e4718c7d5c12a041d61b79cc15c8ba642 | 8b737632eba541c24c4003fbae26b0efc82b3239 | /src/main/java/org/example/entity/operation/Operation.java | 3bb2b7d88f79b7db29c83833fa1ce369afda1c0e | [] | no_license | OjAntoni/mvc-calculator-extended-3.0 | 346f329e17fab464f8d4bd34c18f0919a46a6007 | 2d3e5ca6bc5d047702c25bb766b0c6cdf9fbd29f | refs/heads/main | 2023-07-18T15:29:53.130134 | 2021-09-09T16:45:02 | 2021-09-09T16:45:02 | 404,781,355 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 954 | java | package org.example.entity.operation;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.entity.User;
import org.example.entity.number.AbstractNumber;
import javax.persistence.*;
import java.util.Date;
@Data
@NoArgsConstructor
@Entity
public class Operation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String num1;
private String num2;
private String operationSign;
private String result;
@ManyToOne(cascade = CascadeType.PERSIST)
private User user;
private Date date;
public Operation(long id, AbstractNumber num1, AbstractNumber num2, String operationSign, AbstractNumber result, User user) {
this.id = id;
this.num1 = num1.toString();
this.num2 = num2.toString();
this.operationSign = operationSign;
this.result = result.toString();
this.user = user;
}
}
| [
"noreply@github.com"
] | OjAntoni.noreply@github.com |
42d7f1d9f6e0f4b6a9ef2e79b044434898b0dad1 | 4cab60d16f48c1d1966ef0bf4ba193b322d7716a | /core/src/main/java/com/scalar/db/api/DistributedStorageProvider.java | 2db87edb2092965789d2cf16d3bb2aa2394596f7 | [
"Apache-2.0"
] | permissive | scalar-labs/scalardb | bccff67008135c2bf55ce82561c0796a60ab9c67 | 3361439063d228d0c105da8fd9400db560698080 | refs/heads/master | 2023-09-01T00:13:49.025011 | 2023-08-31T00:45:08 | 2023-08-31T00:45:08 | 151,700,458 | 447 | 43 | Apache-2.0 | 2023-09-13T11:34:07 | 2018-10-05T09:45:30 | Java | UTF-8 | Java | false | false | 1,199 | java | package com.scalar.db.api;
import com.scalar.db.config.DatabaseConfig;
/**
* A class that creates {@link DistributedStorage} and {@link DistributedStorageAdmin} instances.
* Each storage adapter should implement this class to instantiate its implementations of {@link
* DistributedStorage} and {@link DistributedStorageAdmin}. The implementations are assumed to be
* loaded by {@link java.util.ServiceLoader}.
*/
public interface DistributedStorageProvider {
/**
* Returns the name of the adapter. This is for the configuration {@link DatabaseConfig#STORAGE}.
*
* @return the name of the adapter
*/
String getName();
/**
* Creates an instance of {@link DistributedStorage} for the adapter.
*
* @param config a database config
* @return an instance of {@link DistributedStorage} for the adapter
*/
DistributedStorage createDistributedStorage(DatabaseConfig config);
/**
* Creates an instance of {@link DistributedStorageAdmin} for the adapter.
*
* @param config a database config
* @return an instance of {@link DistributedStorageAdmin} for the adapter
*/
DistributedStorageAdmin createDistributedStorageAdmin(DatabaseConfig config);
}
| [
"noreply@github.com"
] | scalar-labs.noreply@github.com |
dfe2046697b06b80a4d2f7896fe459c761eb9c2f | 96e0679e77af1ddcd01f24a8e9f7115999c72086 | /src/main/java/d/designpattern/behavioral/strategy/demo6/ISortAlg.java | d399352f27bb3cb2cb45846ae8700a173a4a1fed | [] | no_license | wayne06/design-pattern | 9447ae33e35a8071bb3d67cad1841902eed1f5c8 | 023e54b73405ba87aaf8cbcd53cb63b60a55f008 | refs/heads/master | 2022-12-20T21:35:42.954274 | 2022-06-22T09:51:54 | 2022-06-22T09:51:54 | 248,004,306 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 116 | java | package d.designpattern.behavioral.strategy.demo6;
public interface ISortAlg {
void sort(String filePath);
}
| [
"zs577215@gmail.com"
] | zs577215@gmail.com |
8000ea0611a52ff5db181c78b2280558b9800d9d | c621e54120f5b3aa4ec3b2ec52e59280adef8d83 | /src/TPFinalEDAT/SistemaViajes.java | 421d7057a799d67c4f0dc3a4847c3fd0e03ecdde | [] | no_license | maggioniduffy/DataStructuresFinalWork | f86d398c7d714b567cf0196569efea35a8616eb8 | 2c878ad59cbb7781f847514c57035a4d8a89cb90 | refs/heads/main | 2023-07-25T08:03:25.486085 | 2021-08-31T12:55:49 | 2021-08-31T12:55:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 58,170 | java | package TPFinalEDAT;
import TPFinalEDAT.Estructuras.HeapPromocion;
import TPFinalEDAT.Dominio.Pasaje;
import TPFinalEDAT.Dominio.Aeropuerto;
import TPFinalEDAT.Dominio.Cliente;
import TPFinalEDAT.Dominio.Vuelo;
import TPFinalEDAT.Dominio.ClaveVuelo;
import TPFinalEDAT.Dominio.ClaveCliente;
import TPFinalEDAT.Estructuras.Grafo;
import TPFinalEDAT.Estructuras.NodoVert;
import TPFinalEDAT.Estructuras.Lista;
import TPFinalEDAT.Estructuras.TablaDeBusqueda;
import TPFinalEDAT.TecladoIn;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class SistemaViajes {
public static void main(String[] args) throws FileNotFoundException, IOException {
Scanner teclado = new Scanner(System.in);
Grafo aeropuertos = new Grafo();
TablaDeBusqueda clientes = new TablaDeBusqueda();
TablaDeBusqueda vuelos = new TablaDeBusqueda();
HashMap<ClaveCliente, Lista> mapeo;
mapeo = new HashMap<ClaveCliente, Lista>();
String ruta = System.getProperty("user.dir") + "\\src\\TPFinalEDAT\\CargaInicial\\salida.txt";
File salida = new File(ruta);
FileWriter s = new FileWriter(salida);
BufferedWriter bw = new BufferedWriter(s);
cargaAeropuertos(aeropuertos, bw);
cargaVuelos(vuelos, aeropuertos, bw);
cargaClientes(clientes, mapeo, bw);
cargaPasajes(vuelos, clientes, mapeo, aeropuertos, bw);
//Preguntar sobre clave cliente, cliente o q onda
boolean seguir = true;
while (seguir) {
System.out.println("Elija una opcion: \n 1) ABM de aereopuertos \n 2) ABM de cliente "
+ "\n 3) ABM de vuelos \n 4) ABM de pasajes \n 5) Consultas sobre clientes \n 6) Consultas sobre vuelos "
+ "\n 7) Consultas sobre tiempos de viaje \n 8) Listado de clientes para promoción. \n 9) Mostrar sistema. \n 10) Mostrar estructuras. \n 11) Parar.");
int res = TecladoIn.readLineInt();
switch (res) {
case 1:
ABMAereopuerto(aeropuertos, vuelos, mapeo, bw);
break;
case 2:
ABMClientes(clientes, mapeo, bw);
break;
case 3:
ABMVuelos(vuelos, aeropuertos, mapeo, clientes, bw);
break;
case 4:
ABMPasajes(mapeo, clientes, vuelos, bw);
break;
case 5:
ConsultasCliente(clientes, mapeo, vuelos);
break;
case 6:
ConsultasVuelos(vuelos);
break;
case 7:
ConsultasSobreTiemposdeViaje(aeropuertos);
break;
case 8:
HeapPromocion h = Promocion(mapeo);
System.out.println(mostrarPromocion(h));
break;
case 9:
MostrarTodo(aeropuertos, vuelos, clientes, mapeo);
break;
case 10:
MostrarEstructuras(aeropuertos, vuelos, clientes, mapeo);
break;
case 11:
seguir = false;
break;
default:
break;
}
}
escrituraFinal(aeropuertos, vuelos, clientes, mapeo, bw);
}
public static String mostrarPromocion(HeapPromocion h) {
HeapPromocion aux = h.clone();
String n = "";
int i = 1;
boolean r = true;
while (r) {
n = n + "Puesto " + i + ":\t " + aux.recuperarCima() + " Cantidad:\t " + aux.getCantCima() + "\n";
r = aux.eliminarCima();
i++;
}
return n;
}
public static void escribirEnLOG(String texto, BufferedWriter bw) throws IOException {
bw.newLine();
bw.append(texto);
bw.flush();
}
public static void MostrarEstructuras(Grafo aero, TablaDeBusqueda vuelos, TablaDeBusqueda clientes, HashMap pasajes) {
boolean seguir = true;
while (seguir) {
System.out.println("¿Que estructura quiere ver? \n 1) Grafo de Aeropuertos. \n 2) AVL de Vuelos.\n 3"
+ ") AVL de Clientes. \n 4) Mapeo Cliente-Pasajes.\n 5) Todas.\n 6) Volver a Menú. \n");
int res = TecladoIn.readLineInt();
switch (res) {
case 1:
System.out.println("Aeropuertos: ");
System.out.println(aero.mostrar());
break;
case 2:
System.out.println("Vuelos");
System.out.println(vuelos.toString());
break;
case 3:
System.out.println("Clientes");
System.out.println(clientes.toString());
break;
case 4:
System.out.println("Pasajes");
System.out.println(pasajes.toString());
break;
case 5:
System.out.println("Vuelos");
System.out.println(vuelos.toString());
break;
case 6:
seguir = false;
break;
default:
break;
}
}
}
public static void escrituraFinal(Grafo g, TablaDeBusqueda v, TablaDeBusqueda c, HashMap h, BufferedWriter bw) throws IOException {
HeapPromocion hp = Promocion(h);
bw.newLine();
bw.write("ESTADO FINAL DEL SISTEMA");
bw.newLine();
bw.write("");
bw.newLine();
Lista anchura = g.enAnchura();
int largo = anchura.longitud();
bw.write("Aeropuertos:");
bw.newLine();
bw.write("");
bw.newLine();
for (int i = 1; i <= largo; i++) {
Aeropuerto a = (Aeropuerto) anchura.recuperar(i);
bw.write(a.toString());
bw.newLine();
}
bw.write(".............");
bw.newLine();
Lista vuelos = v.listarDatos();
largo = vuelos.longitud();
bw.write("Vuelos:");
bw.newLine();
bw.write("");
bw.newLine();
for (int i = 1; i <= largo; i++) {
Vuelo vue = (Vuelo) vuelos.recuperar(i);
bw.write(vue.toString());
bw.newLine();
}
bw.write(".............");
bw.newLine();
Lista clientes = c.listarDatos();
largo = clientes.longitud();
bw.write("Clientes:");
bw.newLine();
bw.write("");
bw.newLine();
for (int i = 1; i <= largo; i++) {
Cliente cli = (Cliente) clientes.recuperar(i);
bw.write(cli.toString());
bw.newLine();
}
bw.write(".............");
bw.newLine();
bw.write("Pasajes:");
bw.newLine();
bw.write("");
bw.newLine();
Iterator it = h.entrySet().iterator();
while (it.hasNext()) {
HashMap.Entry pair = (HashMap.Entry) it.next();
Lista aux = (Lista) pair.getValue();
largo = aux.longitud();
bw.write("Cliente " + pair.getKey() + " tiene los siguientes pasajes: ");
bw.newLine();
for (int i = 1; i <= largo; i++) {
Pasaje pas = (Pasaje) aux.recuperar(i);
bw.write(pas.toString());
bw.newLine();
}
bw.write("");
bw.newLine();
}
bw.write(".............");
bw.newLine();
bw.write("Documentos de clientes ordenados por cantidad de pasajes comprados.");
bw.newLine();
bw.write(mostrarPromocion(hp));
bw.newLine();
bw.write(".............");
bw.flush();
}
public static void cargaPasajes(TablaDeBusqueda v, TablaDeBusqueda c, HashMap h, Grafo g, BufferedWriter bw) throws FileNotFoundException, IOException {
String ruta = System.getProperty("user.dir") + "\\src\\TPFinalEDAT\\CargaInicial\\pasajes.txt";
File f = new File(ruta);
String line = "";
FileReader fi = new FileReader(f);
BufferedReader pasajes = new BufferedReader(fi);
line = pasajes.readLine();
escribirEnLOG("PASAJES", bw);
escribirEnLOG("", bw);
while (line != null) {
int coma = line.indexOf(',');
if (coma != -1) {
String nomvuelo = line.substring(0, coma);
ClaveVuelo aux = new ClaveVuelo(nomvuelo);
if (v.existeClave(aux)) {
ClaveVuelo clave = (ClaveVuelo) v.getClave(aux);
Vuelo vuelo = (Vuelo) v.obtenerInformacion(clave);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String fecha = line.substring(0, coma);
int asientosVendidos = vuelo.getAsientosVendidos(fecha);
if ((asientosVendidos < vuelo.getAsientosTotales()) || asientosVendidos == -1) {
line = line.substring(coma + 1);
coma = line.indexOf(',');
String nroasiento = line.substring(0, coma);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String tipodoc = line.substring(0, coma);
line = line.substring(coma + 1);
int punto = line.indexOf('.');
String nrodoc = line.substring(0, punto);
ClaveCliente auxiliar = new ClaveCliente(tipodoc, nrodoc);
if (c.existeClave(auxiliar)) {
ClaveCliente cc = (ClaveCliente) c.getClave(auxiliar);
Pasaje nuevo = new Pasaje(vuelo, fecha, nroasiento);
Lista listapasajes = (Lista) h.get(cc);
listapasajes.insertar(nuevo, listapasajes.longitud() + 1);
vuelo.sumarVendidos(1, fecha);
escribirEnLOG("Cliente con tipo y nro documento: " + cc.toString() + ", compro el pasaje: " + nuevo, bw);
} else {
escribirEnLOG("No existe cliente con clave: " + auxiliar.toString(), bw);
}
} else {
escribirEnLOG("No quedan asientos en el vuelo del " + fecha, bw);
}
} else {
escribirEnLOG("No existe vuelo con clave: " + aux.toString(), bw);
}
}
line = pasajes.readLine();
}
escribirEnLOG("", bw);
}
public static void cargaAeropuertos(Grafo aeropuertos, BufferedWriter bw) throws FileNotFoundException, IOException {
String ruta = System.getProperty("user.dir") + "\\src\\TPFinalEDAT\\CargaInicial\\aeropuertos.txt";
File f = new File(ruta);
String line = "";
FileReader fi = new FileReader(f);
BufferedReader apuertos = new BufferedReader(fi);
line = apuertos.readLine();
escribirEnLOG("AEROPUERTOS", bw);
escribirEnLOG("", bw);
while (line != null) {
int posF = line.indexOf(',');
String nombre = line.substring(3, posF);
String aux = line.substring(posF + 2);
posF = aux.indexOf(',');
String ciudad = aux.substring(0, posF);
int punto = aux.indexOf('.');
String telefono = aux.substring(posF + 2, punto - 1);
int tel = Integer.parseInt(telefono);
// System.out.println(tel);
Aeropuerto nuevo = new Aeropuerto(nombre, tel, ciudad);
boolean a = aeropuertos.insertarVertice(nuevo);
if (a) {
escribirEnLOG(nuevo.toString(), bw);
}
//System.out.println(ciudad);
//System.out.println(aux);
line = apuertos.readLine();
}
escribirEnLOG("", bw);
}
public static void cargaVuelos(TablaDeBusqueda v, Grafo g, BufferedWriter bw) throws FileNotFoundException, IOException {
String line = "";
String ruta = System.getProperty("user.dir") + "\\src\\TPFinalEDAT\\CargaInicial\\vuelos.txt";
File f = new File(ruta);
FileReader fr = new FileReader(f);
BufferedReader vuelos = new BufferedReader(fr);
line = vuelos.readLine();
escribirEnLOG("VUELOS", bw);
escribirEnLOG("", bw);
while (line != null) {
int coma = line.indexOf(',');
if (coma != -1) {
String clave = line.substring(0, coma);
if (verificarClave(clave)) {
line = line.substring(coma + 1);
coma = line.indexOf(',');
String nombreOrigen = line.substring(0, coma);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String nombreDestino = line.substring(0, coma);
Aeropuerto auxOrigen = new Aeropuerto(nombreOrigen);
Aeropuerto auxDestino = new Aeropuerto(nombreDestino);
if (g.existeVertice(auxOrigen) && g.existeVertice(auxDestino)) {
Aeropuerto origen = (Aeropuerto) g.getElemento(auxOrigen);
Aeropuerto destino = (Aeropuerto) g.getElemento(auxDestino);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String horaSalidaString = line.substring(0, coma);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String horaLlegadaString = line.substring(0, coma);
int Hsalida = Integer.parseInt(horaSalidaString);
int Hllegada = Integer.parseInt(horaLlegadaString);
int minutos = getMinutos(Hsalida, Hllegada);
g.insertarArco(origen, destino, minutos);
line = line.substring(coma + 1);
coma = line.indexOf('.');
String auxAsientos = line.substring(0, coma);
int asientos = Integer.parseInt(auxAsientos);
ClaveVuelo cv = new ClaveVuelo(clave);
Vuelo nuevo = new Vuelo(cv, origen, destino, Hsalida, Hllegada, asientos);
boolean a = v.insertar(cv, nuevo);
if (a) {
escribirEnLOG(nuevo.toString(), bw);
}
} else {
escribirEnLOG("No existe alguno o ninguno de esos aeropuertos. " + clave + " aeropuertos: " + nombreOrigen + ", destino: " + nombreDestino, bw);
}
} else {
escribirEnLOG(clave + " es errónea.", bw);
}
}
line = vuelos.readLine();
}
escribirEnLOG("", bw);
}
public static void cargaClientes(TablaDeBusqueda c, HashMap h, BufferedWriter bw) throws FileNotFoundException, IOException {
String line = "";
String ruta = System.getProperty("user.dir") + "\\src\\TPFinalEDAT\\CargaInicial\\clientes.txt";
File f = new File(ruta);
FileReader fr = new FileReader(f);
BufferedReader clientes = new BufferedReader(fr);
line = clientes.readLine();
escribirEnLOG("CLIENTES", bw);
escribirEnLOG("", bw);
while (line != null) {
int coma = line.indexOf(',');
if (coma != -1) {
String tipoDoc = line.substring(0, coma);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String nroDoc = line.substring(0, coma);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String nombre = line.substring(0, coma);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String apellido = line.substring(0, coma);
line = line.substring(coma + 1);
coma = line.indexOf(',');
String telefono = line.substring(0, coma);
line = line.substring(coma + 1);
int punto = line.indexOf('.');
String domicilio = line.substring(0, punto);
ClaveCliente cc = new ClaveCliente(tipoDoc, nroDoc);
Cliente nuevo = new Cliente(tipoDoc, nroDoc, nombre, apellido, telefono, domicilio);
boolean a = c.insertar(cc, nuevo);
if (a) {
h.put(cc, new Lista());
escribirEnLOG(nuevo.toString(), bw);
}
}
line = clientes.readLine();
}
escribirEnLOG("", bw);
}
public static HeapPromocion Promocion(HashMap h) {
HeapPromocion hp = new HeapPromocion();
Iterator it = h.entrySet().iterator();
while (it.hasNext()) {
HashMap.Entry pair = (HashMap.Entry) it.next();
Lista aux = (Lista) pair.getValue();
int largo = aux.longitud();
hp.insertar(largo, ((ClaveCliente) pair.getKey()));
}
//System.out.println("Tipo y nro de documentos de los clientes ordenados segun cantidad de pasajes comprados: \n" + hp.ordenado());
return hp;
}
public static void MostrarTodo(Grafo a, TablaDeBusqueda v, TablaDeBusqueda c, HashMap h) {
Lista aereopuertos = a.enProfundidad();
int largo = aereopuertos.longitud();
System.out.println("~~~~~~~~~~~~~~");
System.out.println("Aereopuertos: ");
System.out.println("~~~~~~~~~~~~~~");
for (int i = 1; i <= largo; i++) {
System.out.println(((Aeropuerto) (aereopuertos.recuperar(i))).toString() + ", Ciudad: " + ((Aeropuerto) (aereopuertos.recuperar(i))).getCiudad());
}
Lista vuelos = v.listarDatos();
largo = vuelos.longitud();
System.out.println("~~~~~~~~~~~~~~");
System.out.println("Vuelos: ");
System.out.println("~~~~~~~~~~~~~~");
for (int i = 1; i <= largo; i++) {
System.out.println(((Vuelo) vuelos.recuperar(i)).mostrarInfo() + ".");
}
Lista clientes = c.listarDatos();
largo = clientes.longitud();
System.out.println("~~~~~~~~~~~~~~");
System.out.println("Clientes: ");
System.out.println("~~~~~~~~~~~~~~");
for (int i = 1; i <= largo; i++) {
System.out.println(((Cliente) clientes.recuperar(i)).toString() + ". ");
}
System.out.println("~~~~~~~~~~~~~~");
System.out.println("Pasajes");
System.out.println("~~~~~~~~~~~~~~");
Iterator it = h.entrySet().iterator();
while (it.hasNext()) {
HashMap.Entry pair = (HashMap.Entry) it.next();
Lista aux = (Lista) pair.getValue();
largo = aux.longitud();
if (largo > 0) {
System.out.println("Documento cliente: " + ((ClaveCliente) pair.getKey()).toString());
System.out.println("Pasajes:");
for (int i = 1; i <= largo; i++) {
System.out.print(aux.recuperar(i) + ", ");
}
System.out.println("\n.........");
}
}
}
public static void ConsultasSobreTiemposdeViaje(Grafo a) {
Scanner teclado = new Scanner(System.in);
boolean seguir = true;
while (seguir) {
System.out.println("Elija una opción: \n 1) Darnos dos aereopuertos y le decimos si es posible llegar del primero al segundo"
+ "en algún número como máximo de vuelos. \n 2) Darnos dos aereopuertos y le decimos el camino del primero al segundo en el menor tiempo de vuelo."
+ "\n 3) Nada.");
int resp = TecladoIn.readLineInt();
switch (resp) {
case 1:
System.out.println("Como se llama el primer aereopuerto? (Nombre aereonáutico)");
String nombre1 = teclado.nextLine();
Aeropuerto auxOr = new Aeropuerto(nombre1);
System.out.println("Como se llama el segundo aereopuerto? (Nombre aereonáutico)");
String nombre2 = teclado.nextLine();
Aeropuerto auxDe = new Aeropuerto(nombre2);
if (a.existeVertice(auxOr) && a.existeVertice(auxDe)) {
Aeropuerto origen = (Aeropuerto) a.getElemento(auxOr);
Aeropuerto destino = (Aeropuerto) a.getElemento(auxDe);
System.out.println("Cual es su limite de vuelos?");
int cant = TecladoIn.readLineInt();
boolean posible = a.caminoEnXVuelos(origen, destino, cant);
if (posible) {
System.out.println("Si! Es posible.");
} else {
System.out.println("Lo lamentamos,es imposible hacer ese viaje en menos de o en " + cant + " vuelos.");
}
break;
}
case 2:
System.out.println("Como se llama el primer aereopuerto? (Nombre aereonáutico)");
String nombreA = teclado.nextLine();
System.out.println("Como se llama el segundo aereopuerto? (Nombre aereonáutico)");
String nombreB = teclado.nextLine();
Aeropuerto aux1 = new Aeropuerto(nombreA);
Aeropuerto aux2 = new Aeropuerto(nombreB);
if (a.existeVertice(aux1) && a.existeVertice(aux2)) {
Lista liviano = a.liviano(aux1, aux2);
int largo = liviano.longitud();
Lista nombresLiviano = new Lista();
for (int i = 1; i <= largo; i++) {
nombresLiviano.insertar(((Aeropuerto) liviano.recuperar(i)).getNombre(), i);
}
System.out.println("Camino de menor tiempo posible: " + nombresLiviano);
// ESTA MAL EL METODO CORREGIRRRRR
}
break;
case 3:
seguir = false;
break;
}
}
}
public static void ConsultasVuelos(TablaDeBusqueda v) {
Scanner teclado = new Scanner(System.in);
boolean seg = true;
while (seg) {
System.out.println("Elija una opción. \n"
+ "1) Mostrar información de un viaje.\n"
+ "2) Mostrar nombres de vuelos existentes en un rango decidido por usted\n."
+ "3) Nada.\n");
int respuesta = TecladoIn.readLineInt();
switch (respuesta) {
case 1:
ConsultaVuelos1(v);
break;
case 2:
System.out.println("Diganos el nombre del primer vuelo.");
String v1 = teclado.nextLine();
ClaveVuelo aux1 = new ClaveVuelo(v1);
System.out.println("Ahora el del segundo vuelo.");
String v2 = teclado.nextLine();
ClaveVuelo aux2 = new ClaveVuelo(v2);
if (v.existeClave(aux1) && v.existeClave(aux2)) {
ClaveVuelo primer = (ClaveVuelo) v.getClave(aux1);
ClaveVuelo segundo = (ClaveVuelo) v.getClave(aux2);
Lista rangoVuelos = null;
if (primer.compareTo(segundo) <= 0) {
rangoVuelos = v.listarRango(primer, segundo);
} else {
rangoVuelos = v.listarRango(segundo, primer);
}
Lista nombres = new Lista();
int largo = rangoVuelos.longitud();
for (int i = 1; i <= largo; i++) {
nombres.insertar(((ClaveVuelo) rangoVuelos.recuperar(i)).getClave(), i);
}
System.out.println("Vuelos en el rango deseado: " + nombres);
} else {
System.out.println("Vuelos inexistentes.");
}
break;
case 3:
seg = false;
default:
System.out.println("Opción errónea.");
}
}
}
// PREGUNTAR SOBRE FECHASSSS
public static void ConsultaVuelos1(TablaDeBusqueda v) {
Scanner teclado = new Scanner(System.in);
System.out.println("Diganos el nombre del vuelo");
String nombreVuelo = teclado.nextLine();
ClaveVuelo claveV = new ClaveVuelo(nombreVuelo);
if (v.existeClave(claveV)) {
ClaveVuelo clave = (ClaveVuelo) v.getClave(claveV);
Vuelo nuevo = (Vuelo) v.obtenerInformacion(clave);
Lista viajes = nuevo.getViajes();
System.out.println("Viajes del vuelo:");
System.out.println(viajes);
System.out.println("Elija una de las anteriores fechas: ");
String fecha = teclado.nextLine();
int as = nuevo.getAsientosVendidos(fecha);
if (as != -1) {
System.out.println("Información del vuelo: \n" + nuevo.mostrarInfo());
System.out.println("Y se vendieron " + as + " asientos en el vuelo del " + fecha);
} else {
System.out.println("No se vendieron pasajes");
}
}
}
public static Lista pasajesPendientes(HashMap h, ClaveCliente clave) {
// Preguntar por iterator
Lista aux = (Lista) h.get(clave);
Lista res = new Lista();
int largo = aux.longitud();
int j = 1;
for (int i = 1; i <= largo; i++) {
Pasaje n = (Pasaje) aux.recuperar(i);
//System.out.println("pasaje " + n + ", estado del pasaje: " + n.getEstado());
if (n.getEstado() == 0) {
res.insertar(n, j);
j++;
}
}
return res;
}
public static Lista pasajesVolados(HashMap h, ClaveCliente clave) {
// Preguntar por iterator
Lista aux = (Lista) h.get(clave);
Lista res = new Lista();
int largo = aux.longitud();
int j = 1;
for (int i = 1; i <= largo; i++) {
Pasaje n = (Pasaje) aux.recuperar(i);
System.out.println("estado n: " + n.getEstado());
if (n.getEstado() == 1) {
res.insertar(n, j);
j++;
}
}
System.out.println(res);
return res;
}
public static void ConsultasCliente(TablaDeBusqueda c, HashMap m, TablaDeBusqueda v) {
Scanner teclado = new Scanner(System.in);
boolean seguir = true;
while (seguir) { // Qué es información de contacto?
System.out.println("Elija una opción. 1: Verificar y mostrar información de contacto de un cliente. 2: Mostrar ciudades visitadas por algún cliente. 3: Nada. ");
int respuesta = TecladoIn.readLineInt();
switch (respuesta) {
case 1:
System.out.println("Diganos el tipo de documento del cliente a consultar");
String tipoD = teclado.nextLine();
System.out.println("Ahora el numero de documento");
String nroD = teclado.nextLine();
ClaveCliente claveAux = new ClaveCliente(tipoD, nroD);
if (c.existeClave(claveAux)) {
ClaveCliente claveC = (ClaveCliente) c.getClave(claveAux);
System.out.println("Información de contacto: " + ((Cliente) c.obtenerInformacion(claveC)).getNumeroTelefono());
Lista pasajesPend = pasajesPendientes(m, claveC);
Lista res = new Lista();
int larg = pasajesPend.longitud();
/*for(int i=larg; i<=larg;i++){
res.insertar(((Pasaje)pasajesPend.recuperar(i)).toString(), i);
}*/
System.out.println("Pasajes pendientes: " + pasajesPend);
}
break;
case 2:
System.out.println("Diganos el tipo de documento del cliente a consultar");
String tipoDo = teclado.nextLine();
System.out.println("Ahora el numero de documento");
String nroDo = teclado.nextLine();
ClaveCliente claveAux2 = new ClaveCliente(tipoDo, nroDo);
if (c.existeClave(claveAux2)) {
ClaveCliente claveC2 = (ClaveCliente) c.getClave(claveAux2);
Lista visitados = new Lista();
Lista pasajesVola = pasajesVolados(m, claveC2);
int largo = pasajesVola.longitud();
for (int i = 1; i <= largo; i++) {
String ciudad = ((Pasaje) pasajesVola.recuperar(i)).getCiudadDestino();
visitados.insertar(ciudad, i);
}
System.out.println("Ciudades visitadas: " + visitados);
}
break;
case 3:
seguir = false;
break;
}
}
}
public static void ABMPasajes(HashMap h, TablaDeBusqueda c, TablaDeBusqueda v, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Elija una opcion: \n 1) Agregar pasaje. \n 2) Eliminar pasaje. "
+ "\n 3) Modificar pasaje.");
int a = TecladoIn.readLineInt();
switch (a) {
case 1:
PasajesCaso1(h, c, v, bw);
break;
case 2:
PasajesCaso2(h, c, v, bw);
break;
case 3:
PasajesCaso3(h, c, v, bw);
break;
default:
break;
}
}
public static void PasajesCaso3(HashMap h, TablaDeBusqueda c, TablaDeBusqueda v, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
boolean seguir = true;
System.out.println("Diganos el tipo de documento del cliente");
String tipo = teclado.nextLine();
System.out.println("Ahora el numero de documento");
String nroD = teclado.nextLine();
ClaveCliente clave = new ClaveCliente(tipo, nroD);
if (c.existeClave(clave)) {
ClaveCliente cc = (ClaveCliente) c.getClave(clave);
Lista pasajes = (Lista) h.get(cc);
Pasaje pas = (Pasaje) pasajes.recuperar(1);
System.out.println("Cual era el vuelo? Diganos el nombre clave");
String claveV = teclado.nextLine();
ClaveVuelo cv = new ClaveVuelo(claveV);
System.out.println("Y la fecha");
String fecha = teclado.nextLine();
if (v.existeClave(cv)) {
ClaveVuelo claveVuelo = (ClaveVuelo) v.getClave(cv);
Vuelo vue = (Vuelo) v.obtenerInformacion(claveVuelo);
if (vue.verificarFecha(fecha)) {
int i = 2;
while (!pas.getVuelo().equals(vue)) {
pas = (Pasaje) pasajes.recuperar(i);
i++;
}
while (seguir) {
System.out.println("Que desea modificar del pasaje? 1: Asiento. 2: Vuelo. 3: Estado del pasaje. 4: Nada.");
int respuesta = TecladoIn.readLineInt();
switch (respuesta) {
case 1:
System.out.println("Diganos el nuevo asiento");
String nuevoA = teclado.nextLine();
String viejoA = pas.getAsiento();
escribirEnLOG("El pasaje " + pas + " cambió del asiento " + viejoA + " al " + nuevoA, bw);
pas.setAsiento(nuevoA);
break;
case 2:
System.out.println("Diganos la clave del nuevo vuelo");
String cvuelo = teclado.nextLine();
ClaveVuelo aux = new ClaveVuelo(cvuelo);
System.out.println("Y la fecha");
String fechaNueva = teclado.nextLine();
if (v.existeClave(aux)) {
vue.restarVendidos(1, fecha);
ClaveVuelo clav = (ClaveVuelo) v.getClave(aux);
Vuelo nuevo = (Vuelo) v.obtenerInformacion(clav);
nuevo.sumarVendidos(1, fechaNueva);
pas.setVuelo(nuevo);
escribirEnLOG("El pasaje " + pas + " cambió del vuelo " + vue + " al vuelo " + nuevo, bw);
}
break;
case 3:
System.out.println("Diganos la actualización del pasaje.(Volado, Cancelado o Pendiente)");
String estado = teclado.nextLine();
switch (estado) {
case "Pendiente":
pas.setEstado(0);
escribirEnLOG("El pasaje " + pas + " ahora está pendiente", bw);
break;
case "Cancelado":
pas.setEstado(-1);
escribirEnLOG("El pasaje " + pas + " fue cancelado", bw);
break;
case "Volado":
pas.setEstado(1);
escribirEnLOG("El pasaje " + pas + " fue volado", bw);
break;
default:
break;
}
case 4:
seguir = false;
break;
}
}
} else {
System.out.println("No existe un viaje con esa fecha.");
}
} else {
System.out.println("No existe esa clave.");
}
}
}
public static void PasajesCaso2(HashMap h, TablaDeBusqueda c, TablaDeBusqueda v, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Diganos el tipo de documento del cliente");
String tipo = teclado.nextLine();
System.out.println("Ahora el numero de documento");
String nroD = teclado.nextLine();
ClaveCliente claveCliente = new ClaveCliente(tipo, nroD);
if (c.existeClave(claveCliente)) {
ClaveCliente claveC = (ClaveCliente) c.getClave(claveCliente);
Lista pasajes = (Lista) h.get(claveC);
Pasaje pas = (Pasaje) pasajes.recuperar(1);
System.out.println("Cual era el vuelo? Diganos el nombre clave");
String claveV = teclado.nextLine();
ClaveVuelo cvAux = new ClaveVuelo(claveV);
System.out.println("Y la fecha");
String fecha = teclado.nextLine();
if (v.existeClave(cvAux)) {
ClaveVuelo claveVuelo = (ClaveVuelo) v.getClave(cvAux);
Vuelo vue = (Vuelo) v.obtenerInformacion(claveVuelo);
int i = 2;
while (!pas.getVuelo().equals(vue) && pas.getFecha().equals(fecha)) {
pas = (Pasaje) pasajes.recuperar(i);
i++;
}
escribirEnLOG("El cliente " + claveC.toString() + " canceló su pasaje: " + pas.toString(), bw);
pas.setEstado(-1);
vue.restarVendidos(1, fecha);
}
}
}
public static void PasajesCaso1(HashMap h, TablaDeBusqueda c, TablaDeBusqueda v, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Diganos el nombre clave del vuelo para el pasaje");
String claveVuelo = teclado.nextLine();
ClaveVuelo cv = new ClaveVuelo(claveVuelo);
boolean existe = v.existeClave(cv);
if (existe) {
System.out.println("Y la fecha");
String fecha = teclado.nextLine();
ClaveVuelo clave = (ClaveVuelo) v.getClave(cv);
Vuelo delPasaje = (Vuelo) v.obtenerInformacion(clave);
comprarPasaje(delPasaje, v, h, c, fecha, bw);
}
}
public static void comprarPasaje(Vuelo delPasaje, TablaDeBusqueda v, HashMap h, TablaDeBusqueda c, String fecha, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
if (delPasaje.getAsientosVendidos(fecha) < delPasaje.getAsientosTotales()) {
System.out.println("Tipo de documento del cliente?");
String tipo = teclado.nextLine();
System.out.println("Numero de documento?");
String doc = teclado.nextLine();
ClaveCliente claveAux = new ClaveCliente(tipo, doc);
boolean existeCliente = c.existeClave(claveAux);
if (existeCliente) {
ClaveCliente clave = (ClaveCliente) c.getClave(claveAux);
System.out.println("¿Número de asiento?");
String nroA = teclado.nextLine();
Pasaje nuevo = new Pasaje(delPasaje, fecha, nroA);
delPasaje.sumarVendidos(1, fecha);
Lista pasajes = (Lista) h.get(clave);
pasajes.insertar(nuevo, pasajes.longitud() + 1);
escribirEnLOG("El cliente de documento " + clave.toString() + " compró el pasaje " + nuevo, bw);
} // Preguntar que pasa si no hay cliente
}
}
public static void VuelosCaso1(TablaDeBusqueda v, Grafo g, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Cual es el aereopuerto de origen?");
String nomO = teclado.nextLine();
Aeropuerto o = new Aeropuerto(nomO);
System.out.println("Y el de destino?");
String nomD = teclado.nextLine();
Aeropuerto d = new Aeropuerto(nomD);
if (g.existeVertice(d) && g.existeVertice(o)) {
boolean ok = false;
String claveVuelo = "";
while (!ok) {
System.out.println("Diganos el nombre clave del vuelo");
claveVuelo = teclado.nextLine();
ok = verificarClave(claveVuelo);
if (!ok) {
System.out.println("Clave o formato errónea/o, intente de nuevo.");
}
}
ClaveVuelo cv = new ClaveVuelo(claveVuelo);
System.out.println("Cuántos asientos tiene?");
int asientos = TecladoIn.readLineInt();
Aeropuerto origen = (Aeropuerto) g.getElemento(o);
Aeropuerto destino = (Aeropuerto) g.getElemento(d);
System.out.println("A que hora sale el vuelo? Ingresar numero de 4 cifras, las primeras 2 la hora, ultimas 2 los minutos. Sin comas ni puntos");
int horaS = TecladoIn.readLineInt();
System.out.println("A que hora llega el vuelo? Mismo formato que en la hora de salida.");
int horaL = TecladoIn.readLineInt();
int minutos = getMinutos(horaS, horaL);
g.insertarArco(origen, destino, minutos);
Vuelo nuevo = new Vuelo(cv, origen, destino, horaS, horaL, asientos);
boolean a = v.insertar(cv, nuevo);
if (a) {
escribirEnLOG("Se agrego el vuelo " + nuevo, bw);
}
} else {
System.out.println("Lo sentimos, no existen tales aeropuertos.");
}
}
public static int getMinutos(int horaS, int horaL) {
int mins = 0, auxMayor, auxMenor;
if (horaL < horaS) {
horaL = horaL + 2400;
}
auxMayor = (horaL - horaL % 100) - (horaS - horaS % 100);
while (auxMayor > 0) {
mins = mins + 60;
auxMayor = auxMayor - 100;
}
int restoSalida = horaS % 100, restoLlegada = horaL % 100;
if (restoSalida > restoLlegada) {
mins = mins - (restoSalida - restoLlegada);
} else if (restoLlegada > restoSalida) {
mins = mins + (restoLlegada - restoSalida);
}
return mins;
}
public static boolean verificarClave(String clave) {
boolean res = Character.isLetter(clave.charAt(0)) && !Character.isLowerCase(clave.charAt(0))
&& Character.isLetter(clave.charAt(1)) && !Character.isLowerCase(clave.charAt(1))
&& Character.isDigit(clave.charAt(2)) && Character.isDigit(clave.charAt(3)) && Character.isDigit(clave.charAt(4))
&& Character.isDigit(clave.charAt(5));
return res;
}
public static int sumarMinutos(int s, int m) {
int l = s;
while (m >= 60) {
l = l + 100;
m = m - 60;
if (l >= 2400) {
l = 0000 + l % 2400;
}
}
if (l % 100 + m >= 60) {
l = l + 100;
m = (l + m) - 60;
l = l + m;
} else {
l = l + m;
}
return l;
}
public static void VuelosCaso2(TablaDeBusqueda v, Grafo g, HashMap h, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Cual es el aereopuerto de origen?");
//Preguntar sobre si tambien eliminar el arco entre aereopuertos
String nomOr = teclado.nextLine();
Aeropuerto orAux = new Aeropuerto(nomOr);
System.out.println("Y el de destino?");
String nomDe = teclado.nextLine();
Aeropuerto desAux = new Aeropuerto(nomDe);
if (g.existeVertice(orAux) && g.existeVertice(desAux)) {
Aeropuerto origen = (Aeropuerto) g.getElemento(orAux);
Aeropuerto destino = (Aeropuerto) g.getElemento(desAux);
System.out.println("Ahora diganos el nombre clave del vuelo");
String cvuelo = teclado.nextLine();
ClaveVuelo aux = new ClaveVuelo(cvuelo);
if (v.existeClave(aux)) {
ClaveVuelo cv = (ClaveVuelo) v.getClave(aux);
Vuelo s = (Vuelo) v.obtenerInformacion(cv);
//Preguntar sobre eliminación de pasajes.
int minutos = getMinutos(s.getHoraSalida(), s.getHoraLlegada());
g.eliminarArco(origen, destino, minutos);
eliminarTodosLosPasajesDeUnVuelo(h, v, s, bw);
boolean a = v.eliminar(cv);
if (a) {
escribirEnLOG("Se elminó el vuelo: " + s, bw);
}
}
}
escribirEnLOG("", bw);
}
public static void VuelosCaso3(TablaDeBusqueda v, Grafo g, HashMap h, TablaDeBusqueda c, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Diganos la clave del vuelo a modificar");
String clavec = teclado.nextLine();
ClaveVuelo aux = new ClaveVuelo(clavec);
if (v.existeClave(aux)) {
ClaveVuelo clave = (ClaveVuelo) v.getClave(aux);
Vuelo mod = (Vuelo) v.obtenerInformacion(clave);
boolean seguir = true;
while (seguir) {
System.out.println("Que quiere modificar? 1) Hora salida 2) Hora llegada 3) Asientos vendidos 4) Nada");
int respuesta = TecladoIn.readLineInt();
switch (respuesta) {
case 1:
int salidaVieja = mod.getHoraSalida();
System.out.println("Diganos la nueva hora de salida");
int sal = TecladoIn.readLineInt();
mod.setSalida(sal);
Aeropuerto origen = mod.getOrigen();
Aeropuerto destino = mod.getDestino();
int minutos = getMinutos(sal, mod.getHoraLlegada());
g.setEtiqueta(origen, destino, minutos);
escribirEnLOG("Se cambió la hora de salida del vuelo " + mod + " de " + salidaVieja + " pasó a " + sal + " por lo q tambien se cambió la etiq"
+ "ueta de su arco a: " + minutos, bw);
break;
case 2:
int llegadaVieja = mod.getHoraLlegada();
System.out.println("Diganos la nueva hora de llegada");
int lle = TecladoIn.readLineInt();
mod.setLlegada(lle);
Aeropuerto origen2 = mod.getOrigen();
Aeropuerto destino2 = mod.getDestino();
int minutos2 = getMinutos(mod.getHoraSalida(), lle);
g.setEtiqueta(origen2, destino2, minutos2);
escribirEnLOG("Se cambió la hora de llegada del vuelo " + mod + " de " + llegadaVieja + " pasó a " + lle + " por lo q tambien se cambió la etiq"
+ "ueta de su arco a: " + minutos2, bw);
break;
case 3:
//Preguntar sobre que hacer con los pasajes
System.out.println("Si se vendieron asientos, presione 1. Si se cancelaron pasajes presione 2");
int asien = TecladoIn.readLineInt();
if (asien == 1) {
System.out.println("Cuantos?");
int suma = TecladoIn.readLineInt();
System.out.println("En que fecha?");
String fecha = teclado.nextLine();
if (mod.getAsientosVendidos(fecha) + suma <= mod.getAsientosTotales()) {
mod.sumarVendidos(suma, fecha);
for (int i = 1; i <= suma; i++) {
comprarPasaje(mod, v, h, c, fecha, bw);
}
}
} else {
System.out.println("Cuantos?");
int resta = TecladoIn.readLineInt();
System.out.println("En que fecha?");
String fecha = teclado.nextLine();
mod.restarVendidos(resta, fecha);
for (int i = 1; i <= resta; i++) {
eliminarUnPasaje(mod, h, v, c, fecha, bw);
}
}
}
}
}
}
public static void eliminarUnPasaje(Vuelo vuelo, HashMap h, TablaDeBusqueda v, TablaDeBusqueda c, String fecha, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Por favor diganos el tipo de documento del cliente dueño del pasaje a eliminar");
String tipoD = teclado.nextLine();
System.out.println("Ahora el número de documento");
String nroD = teclado.nextLine();
ClaveCliente claveC = new ClaveCliente(tipoD, nroD);
Pasaje pas = null;
if (c.existeClave(claveC)) {
ClaveCliente cc = (ClaveCliente) c.getClave(claveC);
Lista pasajes = (Lista) h.get(cc);
int i = 1;
int largo = pasajes.longitud();
boolean seguir = true;
while (seguir && i <= largo) {
if (((Pasaje) pasajes.recuperar(i)).getVuelo().equals(vuelo) && ((Pasaje) pasajes.recuperar(i)).getFecha().equals(fecha)) {
pas = (Pasaje) pasajes.recuperar(i);
seguir = false;
} else {
i++;
}
}
if (!seguir) {
pas.setEstado(-1);
escribirEnLOG("Se eliminó el pasaje " + pas + ", que era del cliente con documento: " + cc.toString(), bw);
}
}
}
public static void ABMVuelos(TablaDeBusqueda v, Grafo g, HashMap h, TablaDeBusqueda c, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Elija una opcion: \n 1) Agregar vuelo. \n 2) Sacar vuelo. "
+ "\n 3) Modificar vuelo");
int a = TecladoIn.readLineInt();
switch (a) {
case 1:
VuelosCaso1(v, g, bw);
break;
case 2:
VuelosCaso2(v, g, h, bw);
break;
case 3:
VuelosCaso3(v, g, h, c, bw);
break;
}
}
public static void ABMClientes(TablaDeBusqueda c, HashMap h, BufferedWriter bw) throws IOException {
System.out.println("Elija una opcion: \n 1) Agregar cliente. \n 2) Sacar cliente. "
+ "\n 3) Modificar cliente");
int a = TecladoIn.readLineInt();
switch (a) {
case 1:
caso1Cliente(c, h, bw);
break;
case 2:
caso2Cliente(c, h, bw);
break;
case 3:
caso3Cliente(c, bw);
break;
}
}
public static void caso2Cliente(TablaDeBusqueda c, HashMap h, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Diganos el tipo de documento");
String t = teclado.nextLine();
System.out.println("y el numero");
String num = teclado.nextLine();
ClaveCliente aux = new ClaveCliente(t, num);
if (c.existeClave(aux)) {
ClaveCliente clave = (ClaveCliente) c.getClave(aux);
boolean a = c.eliminar(clave);
if (a) {
Lista pasajes = (Lista) h.get(clave);
for (int i = 1; i <= pasajes.longitud(); i++) {
Pasaje p = (Pasaje) pasajes.recuperar(i);
if(p.getEstado()==0){
Vuelo v = p.getVuelo();
String fecha = p.getFecha();
v.restarVendidos(1, fecha);}
}
h.remove(clave);
escribirEnLOG("Se eliminó el cliente con tipo y nro de documento: " + clave.toString(), bw);
}
}
}
public static void caso3Cliente(TablaDeBusqueda c, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Diganos el tipo de documento");
String ti = teclado.nextLine();
System.out.println("y el numero");
String nume = teclado.nextLine();
ClaveCliente aux = new ClaveCliente(ti, nume);
if (c.existeClave(aux)) {
ClaveCliente key = (ClaveCliente) c.getClave(aux);
Cliente modificable = (Cliente) c.obtenerInformacion(key);
System.out.println("Si quiere modificar el numero de telefono, responda 'T', si quiere modificar el domicilio responda 'D'");
char r = TecladoIn.readLineNonwhiteChar();
if (r == 'T') {
String nroViejo = modificable.getNumeroTelefono();
System.out.println("Cual es el nuevo numero?");
String nuevo = teclado.nextLine();
modificable.setNumeroTelefono(nuevo);
escribirEnLOG("Se cambió el numero de telefono del cliente " + modificable + ", de " + nroViejo + " pasó a " + nuevo, bw);
} else {
if (r == 'D') {
String dom = modificable.getDomicilio();
System.out.println("Diga el nuevo domicilio");
String l = teclado.nextLine();
modificable.setDomicilio(l);
escribirEnLOG("Se cambió el domicilio del cliente " + modificable + ", de " + dom + " pasó a " + l, bw);
}
}
}
}
public static void caso1Cliente(TablaDeBusqueda c, HashMap h, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
System.out.println("Diganos los datos del cliente \n Tipo documento?");
String tipo = teclado.nextLine();
System.out.println("El numero de documento ahora: ");
String nro = teclado.nextLine();
ClaveCliente cc = new ClaveCliente(tipo, nro);
if (!c.existeClave(cc)) {
System.out.println("Diganos su nombre");
String nombre = teclado.nextLine();
System.out.println("Apellido: ");
String ap = teclado.nextLine();
System.out.println("Telefono");
String tel = teclado.nextLine();
System.out.println("Y el domicilio");
String dom = teclado.nextLine();
Cliente cli = new Cliente(tipo, nro, nombre, ap, tel, dom);
boolean a = c.insertar(cc, cli);
if (a) {
h.put(cc, new Lista());
escribirEnLOG("Se agrego el cliente " + cli, bw);
}
}
}
public static void ABMAereopuerto(Grafo aereopuertos, TablaDeBusqueda v, HashMap h, BufferedWriter bw) throws IOException {
Scanner teclado = new Scanner(System.in);
boolean seguir = true;
while (seguir) {
System.out.println("Elija una opcion: \n 1) Agregar aereopuerto. \n 2) Modificar aereopuerto. "
+ "\n 3) Nada");
int a = TecladoIn.readLineInt();
switch (a) {
case 1:
System.out.println("Diganos la clave del nuevo aereopuerto");
String nombreClave = teclado.nextLine();
Aeropuerto aux = new Aeropuerto(nombreClave);
if (!aereopuertos.existeVertice(aux)) {
System.out.println("En que ciudad queda el aereopuerto?");
String city = teclado.nextLine();
System.out.println("Y cuál es el número de teléfono?");
int nroTel = TecladoIn.readLineInt();
aux = new Aeropuerto(nombreClave, nroTel, city);
boolean x = aereopuertos.insertarVertice(aux);
if (x) {
escribirEnLOG("Se agrego el aeropuerto " + aux, bw);
}
}
break;
case 2:
System.out.println("Diganos la clave del aereopuerto a modificar");
String ar = teclado.nextLine();
Aeropuerto x1 = new Aeropuerto(ar);
boolean e = aereopuertos.existeVertice(x1);
System.out.println(e);
if (e) {
Aeropuerto m = (Aeropuerto) aereopuertos.getElemento(x1);
int nroViejo = m.getTelefono();
System.out.println("Ingrese numero de telefono, es lo unico modificable del aereopuerto");
int n = TecladoIn.readLineInt();
m.setNumero(n);
escribirEnLOG("Se cambió el número de telefono del aeropuerto " + m + ", pasó de " + nroViejo + " a " + n, bw);
}
break;
case 3:
seguir = false;
break;
default:
break;
}
}
}
public static void eliminarTodosLosPasajesDeUnVuelo(HashMap h, TablaDeBusqueda v, Vuelo vuelo, BufferedWriter bw) throws IOException {
Iterator it = h.entrySet().iterator();
escribirEnLOG("Se eliminan todos los pasajes del vuelo: " + vuelo, bw);
while (it.hasNext()) {
HashMap.Entry pair = (HashMap.Entry) it.next();
Lista aux = (Lista) pair.getValue();
int largo = aux.longitud();
for (int i = 1; i <= largo; i++) {
Pasaje pas = (Pasaje) aux.recuperar(i);
if (pas.getVuelo().equals(vuelo)) {
escribirEnLOG("Se elimina pasaje: " + pas, bw);
pas.setEstado(-1);
}
}
}
// averiguar bien sobre iterator
}
}
| [
"Faustino@LAPTOP-VI7AL9FL"
] | Faustino@LAPTOP-VI7AL9FL |
48e8d45bddbf0fb17d49f15c8569b73d97ea8b14 | 6429eeaaab5268ff2ea21e6ac09988be3bd19511 | /src/ppo/labDodatkowy/Odcinki/Odcinki.java | 0197b70aeef8364da2db80c4175558174a0aa214 | [] | no_license | radek-p/PPO | 9204cbbd12875b7f7b240afdd7177bbfb8d2c860 | ffa0770fa7b618f8fd83b73e1a05403f1a9b3168 | refs/heads/master | 2020-08-31T14:49:12.548933 | 2020-02-05T10:00:20 | 2020-02-05T10:00:20 | 218,714,878 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 181 | java | package ppo.labDodatkowy.Odcinki;
public abstract class Odcinki {
public abstract boolean dodaj(Odcinek dodawany);
public abstract boolean sprawdźCzyNależy(int punkt);
}
| [
"r.piorkowski@mimuw.edu.pl"
] | r.piorkowski@mimuw.edu.pl |
c07b03695aebe8e7740ad191497c6723fe216306 | 2bd400e348cf451a7196c91ddd60f99539e51dc6 | /src/com/gingerdroids/crossword/QualityMeasureFactory.java | bda48e2d2d476841ad5abdc2b85782063020d439 | [] | no_license | gingerdroids/Crosswords | a081d869ff1049506b7b6b7338b9e8ce9bd465f9 | a495eb438f4f40fcc15d7206f63a85b9a753bd11 | refs/heads/main | 2023-02-22T15:51:05.622713 | 2021-01-24T00:43:32 | 2021-01-24T00:43:32 | 332,337,858 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 161 | java | package com.gingerdroids.crossword;
public interface QualityMeasureFactory {
QualityMeasure makeQualityMeasure(int totalWordCount, int currentWordCount);
}
| [
"guy@multiniche.org"
] | guy@multiniche.org |
d5bb7cde3271b34c930c99485199c01550e63caa | 4209b51f75e0d68f72253d63987a8a427b4349fd | /src/main/java/com/example/demo/domain/provider/integration/Venue.java | bbd6c63fe80f1126a4a976321fd2cc4205f6a420 | [] | no_license | szisti/demo | 423e61981ef80b98fb9088b381b5fdec967a99f3 | 412805fd201a35172a4f6d8f800d617596b8c22b | refs/heads/master | 2021-01-18T11:57:13.049113 | 2017-08-15T15:12:45 | 2017-08-15T15:12:45 | 100,361,692 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,371 | java | package com.example.demo.domain.provider.integration;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
public class Venue {
@JsonProperty("Id")
private int id;
@JsonProperty("Name")
private String name;
@JsonProperty("Region")
private Region region;
@JsonProperty("Capacity")
private Integer capacity;
@JsonProperty("Latitude")
private BigDecimal latitude;
@JsonProperty("Longitude")
private BigDecimal longitude;
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 Region getRegion() {
return region;
}
public void setRegion(Region region) {
this.region = region;
}
public Integer getCapacity() {
return capacity;
}
public void setCapacity(Integer capacity) {
this.capacity = capacity;
}
public BigDecimal getLatitude() {
return latitude;
}
public void setLatitude(BigDecimal latitude) {
this.latitude = latitude;
}
public BigDecimal getLongitude() {
return longitude;
}
public void setLongitude(BigDecimal longitude) {
this.longitude = longitude;
}
}
| [
"istvan.szabo@betvictor.com"
] | istvan.szabo@betvictor.com |
1a1f27243e1412d08280ed071a368639c4aede58 | 7fac82dfd712b5c4684c118e590d427b4eb577ed | /dakara.eclipse.commander.plugin/src/dakara/eclipse/plugin/command/settings/PersistedWorkingSet.java | a7a22ba83a5074e5c9998df0988ba20b376fd6f9 | [
"MIT"
] | permissive | fabioz/eclipse-plugin-commander | 5321932c95a362ae3d719076ca520b10875ee1b5 | 64c0ea5d876ad044bbd62ce75087ead52bf76699 | refs/heads/master | 2023-08-02T06:43:06.969578 | 2017-09-19T13:38:19 | 2017-09-19T13:38:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,971 | java | package dakara.eclipse.plugin.command.settings;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import dakara.eclipse.plugin.command.Constants;
import dakara.eclipse.plugin.log.EclipsePluginLogger;
public class PersistedWorkingSet<T> {
private EclipsePluginLogger logger = new EclipsePluginLogger(Constants.BUNDLE_ID);
private final int historyLimit;
private List<HistoryEntry> currentEntries = new ArrayList<>();
private boolean historyChangedSinceCheck = false;
public final Function<T, HistoryKey> historyItemIdResolver;
public final Function<HistoryKey, T> historyItemResolver;
private CommanderSettings commanderSettings = new CommanderSettings(new ArrayList<HistoryEntry>());
private EclipsePreferencesSerializer<CommanderSettings> eclipsePreferencesSerializer;
static final String HISTORY_KEY = "HISTORY";
public PersistedWorkingSet(String id, int historyLimit, Function<T, HistoryKey> historyItemIdResolver, Function<HistoryKey, T> historyItemResolver) {
this.historyLimit = historyLimit;
this.historyItemIdResolver = historyItemIdResolver;
this.historyItemResolver = historyItemResolver;
this.eclipsePreferencesSerializer = new EclipsePreferencesSerializer<>(id, HISTORY_KEY);
}
public PersistedWorkingSet<T> save() {
try {
eclipsePreferencesSerializer.saveSettings(commanderSettings);
} catch (Throwable e) {
logger.error("Unable to save settings", e);
}
return this;
}
public PersistedWorkingSet<T> load() {
try {
commanderSettings = eclipsePreferencesSerializer.loadSettings(CommanderSettings.class);
} catch (Throwable e) {
logger.error("Unable to restore settings and history", e);
}
if (commanderSettings == null) commanderSettings = new CommanderSettings(new ArrayList<HistoryEntry>());
return this;
}
private void checkAndClearOnChanged() {
if (historyChangedSinceCheck) {
currentEntries.clear();
}
historyChangedSinceCheck = false;
}
public List<HistoryEntry> getHistory() {
checkAndClearOnChanged();
if (!currentEntries.isEmpty()) return currentEntries;
for (HistoryEntry entry : commanderSettings.entries) {
try {
entry.historyItem = historyItemResolver.apply(entry.entryId);
if (entry.historyItem != null)
currentEntries.add(entry);
} catch (Exception e) {
logger.error("unable to restore history entry " + entry.entryId, e);
}
}
return currentEntries;
}
public HistoryEntry getHistoryEntry(T historyItem) {
HistoryEntry newHistoryEntry = makeEntry(historyItem);
final int index = commanderSettings.entries.indexOf(newHistoryEntry);
if (index > -1) return commanderSettings.entries.get(index);
return null;
}
public PersistedWorkingSet<T> addToHistory(T historyItem) {
historyChangedSinceCheck = true;
HistoryEntry newHistoryEntry = makeEntry(historyItem);
final int existingIndex = commanderSettings.entries.indexOf(newHistoryEntry);
if (existingIndex > -1) newHistoryEntry = commanderSettings.entries.get(existingIndex); // get existing so we keep other attributes. We just want to move to first in the list
commanderSettings.entries.remove(newHistoryEntry);
commanderSettings.entries.add(0, newHistoryEntry);
// count items that are not favorites and which have a valid item reference
if (commanderSettings.entries.stream().filter(entry->!entry.keepForever && entry.historyItem != null).count() > historyLimit) {
HistoryEntry lastRecentEntry = commanderSettings.entries.stream().filter(entry->!entry.keepForever && entry.historyItem != null).reduce((a, b) -> b).orElse(null);
if(lastRecentEntry != null)
commanderSettings.entries.remove(commanderSettings.entries.indexOf(lastRecentEntry));
}
return this;
}
public PersistedWorkingSet<T> setContentMode(String mode) {
commanderSettings.contentMode = mode;
return this;
}
public String getContentMode() {
return commanderSettings.contentMode;
}
public PersistedWorkingSet<T> setHistoryPermanent(T historyItem, boolean permanent) {
historyChangedSinceCheck = true;
HistoryEntry entry = makeEntry(historyItem);
int index = commanderSettings.entries.indexOf(entry);
if (index == -1) {
entry.keepForever = true;
commanderSettings.entries.add(entry);
return this;
}
entry = commanderSettings.entries.get(index);
entry.keepForever = permanent;
return this;
}
public PersistedWorkingSet<T> removeHistory(T historyItem) {
historyChangedSinceCheck = true;
commanderSettings.entries.remove(makeEntry(historyItem));
return this;
}
public class CommanderSettings {
private final List<HistoryEntry> entries;
private String contentMode;
public CommanderSettings(List<HistoryEntry> entries) {
this.entries = entries;
}
}
private HistoryEntry makeEntry(T item) {
return new HistoryEntry(historyItemIdResolver.apply(item));
}
public static class HistoryKey {
public final List<String> keys;
public HistoryKey(String ... keys) {
this.keys = Arrays.asList(keys);
}
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null) return false;
return keys.equals(((HistoryKey)obj).keys);
}
@Override
public int hashCode() {
return keys.hashCode();
}
}
public class HistoryEntry {
public final HistoryKey entryId;
public boolean keepForever = false;
private transient T historyItem;
public HistoryEntry(HistoryKey entryId) {
this.entryId = entryId;
}
public T getHistoryItem() {
return historyItem;
}
@Override
public String toString() {
return entryId.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null) return false;
if (!(obj instanceof PersistedWorkingSet.HistoryEntry)) return false;
return entryId.equals(((HistoryEntry)obj).entryId);
}
@Override
public int hashCode() {
return entryId.hashCode();
}
}
}
| [
"chad.meadows@gmail.com"
] | chad.meadows@gmail.com |
ed046dfaa7b3425ba53bc243579d612f2e438a20 | 41b606d6d104771104a62e18887b302f2611e416 | /src/main/java/cn/jugame/http/SimpleHttpRequestHandler.java | 909f4e0861bc4031687b15dc08048df88716636a | [] | no_license | zhangzj001/mtservice | ccd206f93aeb84fec230d63112e16454a9c5f787 | 22900aa490597cdb51751b0c9e55c9e9f3e6aad5 | refs/heads/master | 2020-03-18T23:26:15.943129 | 2018-07-13T02:52:19 | 2018-07-13T02:52:19 | 135,402,745 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,233 | java | package cn.jugame.http;
import cn.jugame.http.router.Action;
import cn.jugame.http.router.Router;
public class SimpleHttpRequestHandler extends HttpJob{
private Router router = new Router();
public SimpleHttpRequestHandler() {
//初始化路由器
router.init();
}
@Override
protected boolean handleRequest(HttpRequest req, HttpResponse resp) {
String method = req.getMethod();
//根据方法来处理
if("GET".equalsIgnoreCase(method))
return doGet(req, resp);
else if("POST".equalsIgnoreCase(method))
return doPost(req, resp);
else
return doOtherMethod(req, resp);
}
protected boolean doGet(HttpRequest req, HttpResponse resp){
return doHandle(req, resp);
}
protected boolean doPost(HttpRequest req, HttpResponse resp){
return doHandle(req, resp);
}
protected boolean doOtherMethod(HttpRequest req, HttpResponse resp){
return true;
}
/**
* 请求处理方法,在<code>doGet</code>和<code>doPost</code>中都默认调用该方法处理。
* @param req
* @param resp
* @return
*/
protected boolean doHandle(HttpRequest req, HttpResponse resp){
Action action = router.get(req.getUri());
if(action != null){
action.invoke(req, resp);
}
return true;
}
}
| [
"zhangzj001@gmail.com"
] | zhangzj001@gmail.com |
4189422d38fb7a464ef5e3d65cf326cf446a3049 | e2045dd480cd83e3fb9854b568fe83fd73aec94a | /src/java/entity/Food.java | b4bffa8409440263961c653139ea30853085c64c | [] | no_license | OneTwoTen/Assignment_PRJ301 | 04ccf6abafdc0d385d418088224938872751826a | 836935d4b9e27b9878e25ea6364924f322125133 | refs/heads/main | 2023-09-04T08:13:19.911089 | 2021-10-26T08:23:20 | 2021-10-26T08:23:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,490 | 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 entity;
import java.math.BigDecimal;
import java.util.List;
/**
*
* @author doan7
*/
public class Food {
private int id;
private String name;
private Category category;
private BigDecimal price;
private List<FoodOrder> foodOrders ;
public List<FoodOrder> getFoodOrders() {
return foodOrders;
}
public void setFoodOrders(List<FoodOrder> foodOrders) {
this.foodOrders = foodOrders;
}
public Food() {
}
public Food(int id, String name, Category category, BigDecimal price, List<FoodOrder> foodOrders) {
this.id = id;
this.name = name;
this.category = category;
this.price = price;
this.foodOrders = foodOrders;
}
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 Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
}
| [
"khanhdvhe151416@fpt.edu.vn"
] | khanhdvhe151416@fpt.edu.vn |
520bbf0d07e4e719e6b1fa1d621b492b6ee960b5 | 426794720f48dc8a5b0833895995418e5f182356 | /design-patterns/src/main/java/com/xlx/pattern/observer/ConcreteSubject.java | 4ec266801e8cf6d789c33b2228dc6a511e1fcd26 | [] | no_license | xuelingxiao/java-knowledge-structure | 053ba4d89e0c734f20805a3675193a12e26984b0 | 24f582a5070f0ba0b207f440dee29537af017fd5 | refs/heads/master | 2020-03-27T06:04:26.461570 | 2018-10-24T10:25:55 | 2018-10-24T10:25:55 | 145,992,720 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 472 | java | package com.xlx.pattern.observer;
import lombok.Data;
/**
* 具体主题角色
*/
@Data
public class ConcreteSubject extends Subject {
private String name;
public void change() {
this.setName("王多鱼");
super.notifyObservers();
}
public static void main(String[] args) {
new ConcreteSubject()
.register(new UncleObserver())
.register(new HentaiObserver())
.change();
}
}
| [
"xuelinxiao@163.com"
] | xuelinxiao@163.com |
4d79eb58d7f6c376e56071bb857581b3a7fbc953 | 5c5805851adb1f15b7ba95fe74350d8eca6276dc | /lesson03-cdi-pe/src/main/java/org/jboss/ee6lab/cdi/wumpus/PlayerLogoffEvent.java | 3ebeb944e64eeaea8fcfc9e12b0d85a9f337e10d | [] | no_license | rhusar/pv243 | 0691f6e2c520b83ddcdeb548b168d02a5e47e1d3 | 795fbf7da178526f20210a06e8c23551de958165 | refs/heads/master | 2021-01-15T17:02:26.209706 | 2013-11-22T00:24:36 | 2013-11-22T00:24:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 95 | java | package org.jboss.ee6lab.cdi.wumpus;
public class PlayerLogoffEvent extends PlayerEvent {
}
| [
"maschmid@redhat.com"
] | maschmid@redhat.com |
3c88bd18d0759ae26ca9591b6cd923e07ef53fa3 | c3ed94e1e761a369a893e8f5b73b2fc83628ea37 | /ST-BLE-Mesh_App/BlueSTSDK/src/main/java/com/st/BlueSTSDK/Features/emul/FeatureRandomFreeFall.java | 6fc0d1ce19037b80211266a6dfdb0a50ab1fa82f | [] | no_license | rawatsaurabh/stblemesh | 8b2e023e0c18b980d99b65ffb3f6598d39b7b46a | b049c9d1fbd306cb002a9286e06e8cabd68f80d0 | refs/heads/master | 2022-10-23T01:15:35.898983 | 2020-06-16T08:17:32 | 2020-06-16T08:17:32 | 256,130,491 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,581 | java | /*******************************************************************************
* COPYRIGHT(c) 2015 STMicroelectronics
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the name of STMicroelectronics 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 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 com.st.BlueSTSDK.Features.emul;
import com.st.BlueSTSDK.Features.FeatureFreeFall;
import com.st.BlueSTSDK.Node;
import com.st.BlueSTSDK.NodeEmulator;
import java.util.Random;
/**
* generate random data for emulate the class {@link FeatureFreeFall}
*
* @author STMicroelectronics - Central Labs.
* @version 1.0
*/
public class FeatureRandomFreeFall extends FeatureFreeFall implements NodeEmulator.EmulableFeature {
private Random mRnd = new Random();
public FeatureRandomFreeFall(Node parent) {
super(parent);
}
@Override
public byte[] generateFakeData() {
byte [] ret = new byte[1];
float delta = 100;
short rndData = (short) ((0 + delta * mRnd.nextFloat()));
ret[0] = rndData > 90 ? (byte)1 : 0;
return ret;
}
}
| [
"saurabh.rawat@st.com"
] | saurabh.rawat@st.com |
b0daf419b81e1f48098834cf3e627a088e984353 | 2a50a4918e11be5544d9aa904042c8d3ecc74453 | /src/a4New/PriorityQueue.java | 28e538d10e0b95fd00681b7a479a270aa4366bd0 | [] | no_license | beststarry/CS2110Projects | 31614fb19d378d55d2f72861bc28789ee2d1c87c | 867a17534eb6ff7fda9ddc074948921cdc56e1f1 | refs/heads/master | 2022-02-12T00:06:27.070275 | 2019-08-07T20:26:46 | 2019-08-07T20:26:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,943 | java | package a4New;
import java.util.Comparator;
import java.util.NoSuchElementException;
/**
* A priority queue stores elements of type E with priorities of
* type P (typically P is Integer or Double).
*
* This particular interface also only allows one copy of a given element to
* be stored. That is, if you try to add an element e where e.equals(f) for
* some f in this, add will throw an exception.
*
* In the efficiency requirements below, n refers to this.size(). For example,
* poll() says it should run in O(log n) time; this means it should run in time
* logarithmic in the number of elements in the queue.
*/
public interface PriorityQueue<E, P> {
/** return the comparator used for ordering priorities */
public Comparator<? super P> comparator();
/** Return the number of elements in this. Runs in O(1) time. */
public int size();
/**
* Remove and return the largest element of this, according to comparator()
* Runs in O(log n) time.
*
* @throws NoSuchElementException if this is empty
*/
public E poll() throws NoSuchElementException;
/**
* Return the largest element of this, according to comparator().
* Runs in O(1) time.
*
* @throws NoSuchElementException if this is empty.
*/
public E peek() throws NoSuchElementException;
/**
* Add the element e with priority p to this. Runs in O(log n + a) time,
* where a is the time it takes to append an element to an ArrayList of size
* n.
*
* @throws IllegalArgumentException if this already contains an element that
* is equal to e (according to .equals())
*/
public void add(E e, P p) throws IllegalArgumentException;
/**
* Change the priority associated with e to p.
*
* @throws NoSuchElementException if this does not contain e.
*/
public void changePriority(E e, P p) throws NoSuchElementException;
}
| [
"zw587@cornell.edu"
] | zw587@cornell.edu |
786c4b73aba918f39e9b20427da76df719c397f9 | fff33132944533d8d6c6fcbb0392e8db69e379d2 | /JavaTutorial/src/com/cice/tutorialjava/poo/collections/ListTest.java | a800c590ec914c63a8a96bf20456d39d86e612c9 | [] | no_license | CarmenGit/moviles_codigo_abierto | 6a62d86821be70a4be8e84f6c4aa8fc66ee26963 | 7a0fadd2fb41333fc3ef157d2324e2f002821f19 | refs/heads/master | 2021-01-11T22:59:45.075567 | 2017-01-13T09:06:23 | 2017-01-13T09:06:23 | 78,532,103 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,398 | java | package com.cice.tutorialjava.poo.collections;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.cice.tutorialjava.poo.interfaces.Racional;
public class ListTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
List<String> myStringList=new ArrayList<>();
//buscamos una que implemente List
List<Racional> myRacionalList=new ArrayList<>();
myStringList.add("Luis");
myStringList.add("Luis");
myStringList.add("Lola");
myStringList.add("Juan");
myStringList.add("Lui");
System.out.println("Recorriendo la lista con for indexado");
for(int i=0; i<=myStringList.size();i++){
System.out.println(myStringList.get(i));
}
for(String str:myStringList){
System.out.println(str);
}
System.out.println("Recorriendo la lista con iterador");
Iterator<String> it=myStringList.iterator();
while(it.hasNext()){
String str=it.next();
System.out.println(str);
}
System.out.println("Recorriendo la lista con racionales");
myRacionalList.add(new Racional(2,3));
myRacionalList.add(new Racional(1,3));
myRacionalList.add(new Racional(2,7));
myRacionalList.add(new Racional(9,3));
myRacionalList.add(new Racional(2,3));
myRacionalList.add(new Racional(2,6));
Iterator<Racional> it2=myRacionalList.iterator();
while(it2.hasNext()){
System.out.println(it2.next());
}
}
}
| [
"joelfernandezreviejo@gmail.com"
] | joelfernandezreviejo@gmail.com |
7e318391dc63c62e5d9f5546d8b8ac110eefdbce | 10758200a7162100abb7edb1773fb2d36abc3c91 | /src/ordt/output/RegProperties.java | 3d58857a63d4a5bfd8d21e50de83b5d2850ad529 | [
"Apache-2.0"
] | permissive | dattamiruke/open-register-design-tool | 4a69433399a3cb560d5dac2b64dc64a035e47f7e | fc5512b1545f820c720a55c7a176f83aa77646cc | refs/heads/master | 2020-04-03T16:37:24.064167 | 2016-06-21T14:55:14 | 2016-06-21T14:55:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,878 | java | /*
* Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
*/
package ordt.output;
import ordt.extract.Ordt;
import ordt.extract.ModComponent;
import ordt.extract.ModInstance;
import ordt.extract.ModRegister;
import ordt.extract.PropertyList;
import ordt.extract.RegNumber;
import ordt.parameters.ExtParameters;
import ordt.parameters.Utils;
/** extracted properties of a register instance created during model walk */
public class RegProperties extends AddressableInstanceProperties {
private Integer regWidth = ExtParameters.getMinDataSize(); // default to 32b register
private JspecCategory category = new JspecCategory(""); // category property
private Integer filledBits = 0; // initially no fields instanced
private Integer fieldCount = 0; // initially no fields instanced
private int [] availableBits; // track available bit locations in reg as fields added
private int fieldSetOffset = 0; // current accumulated field offset used to compute new index
private boolean fieldOffsetsFromZero; // field offset direction for this reg
private String aliasedId = ""; // if this reg instance is an alias, store base instance
private boolean hasInterruptFields = false; // reg contains interrupt fields
// output-specific status info
private boolean hasInterruptOutputDefined = false; // reg has interrupt output
private boolean hasHaltOutputDefined = false; // reg has halt output
// register properties - will be true if any field has corresponding access
private boolean isSwReadable = false;
private boolean isSwWriteable = false;
// uvmregs test info
private boolean isMem = false;
// cppmod info
private boolean cppModPrune = false;
// jspec attributes
private String jspecAttributes;
/** init properties using defaults -> component -> instance values */
public RegProperties(ModInstance regInst, boolean fieldOffsetsFromZero) {
super(regInst); // init instance, id, external
this.fieldOffsetsFromZero = fieldOffsetsFromZero;
}
// TODO - add clone constructor and display for regprops
/** extract properties from the calling instance */
@Override
public void extractProperties(PropertyList pList) {
super.extractProperties(pList); // extract common parameters
// go directly to extractInstance to get reg width, external, and alias parms
// set reg width and initialize fields for field addition
setRegWidth(); // set the width of this reg based on properties
// initially all bits available for field assignment
//System.out.println("RegProperties extractProperties: regwidth=" + getRegWidth());
availableBits = new int [getRegWidth() + 1]; // initializes all to 0
availableBits[0] = getRegWidth();
/*if (getInstancePath().contains("stats.spin")) {
//display();
System.out.println("RegProperties extractInstance: inst=" + getInstancePath() + ", parmlist=" + pList);
}*/
if (extractInstance.hasProperty("aliasedId")) {
//System.out.println("RegProperties: creating properties for aliased register, id=" + regInst.getId() + ", aliasedId=" + regInst.getProperty("aliasedId") );
setAliasedId(extractInstance.getProperty("aliasedId"));
}
// set external decode
if (pList.hasTrueProperty("external_decode")) setExternalDecode(true);
// otherwise check register width
else checkRegWidth();
// now extract from the combined instance properties
// extract boolean test properties
if (pList.hasTrueProperty("donttest")) setDontTest(true);
if (pList.hasTrueProperty("dontcompare")) setDontCompare(true);
// extract jspec attributes to be passed thru
if (pList.hasProperty("js_attributes")) setJspecAttributes(pList.getProperty("js_attributes"));
// category property
if (pList.hasProperty("category")) {
String catStr = pList.getProperty("category");
setCategory(catStr);
}
// extract uvmregs test info
if (pList.hasTrueProperty("uvmreg_is_mem")) setMem(true);
// extract c++ model info
if (pList.hasTrueProperty("cppmod_prune")) setCppModPrune(true);
}
/** set the width of register based on instance/component properties
*/
private void setRegWidth() {
ModComponent regComp = extractInstance.getRegComp(); // get the component of this instance
// if instance prop is set then use it
if (extractInstance.hasProperty("regwidth"))
regWidth = extractInstance.getIntegerProperty("regwidth");
// otherwise look for a regwidth set in component // TODO - is this needed or will always be picked up in instance props?
else if ((regComp != null) && (regComp.hasProperty("regwidth"))) {
regWidth = regComp.getIntegerProperty("regwidth");
}
// else use default min reg size
if (regWidth==null) regWidth = ExtParameters.getMinDataSize();
//System.out.println("setting width to " + regWidth);
}
private void checkRegWidth() {
// check for valid regwidth
//if (!Utils.isPowerOf2(regWidth))
// Jrdl.warnMessage("Non power of 2 register width (" + regWidth + ") specified in " + extractInstance.getFullId() + ". Address alignment must be on next highest power of 2.");
if (!Utils.isInRange(regWidth, 32, 1024))
Ordt.errorMessage("Invalid register width (" + regWidth + ") specified in " + extractInstance.getFullId() + ". Size should be between 32 and 1024.");
}
/** set the width of register directly
*/
public void setRegWidth(Integer width) {
regWidth = width;
// check for valid regwidth
if ((regWidth % ExtParameters.getMinDataSize()) != 0) {
Ordt.errorMessage("invalid register width (" + regWidth + ") specified");
}
}
/** get regWidth
*/
public Integer getRegWidth() {
return regWidth;
}
/** get regWidth in bytes
*/
public Integer getRegByteWidth() {
return getRegWidth()/8;
}
/** get regWidth in words
*/
public Integer getRegWordWidth() {
return getRegWidth()/ExtParameters.getMinDataSize();
}
/** get the address stride for this reg (specified increment or width) */
public RegNumber getAddrStride() {
RegNumber incr = this.getExtractInstance().getAddressIncrement();
if (incr == null) {
// bump repeat stride to next power of 2
int incBytes = !Utils.isPowerOf2(this.getRegWidth()) ? (Utils.getNextHighestPowerOf2(this.getRegWidth())/8) : this.getRegByteWidth();
incr = new RegNumber(incBytes);
}
return incr;
}
/** get bits needed to address register words // TODO - dup with getRegWordBits?
*/
public Integer getRegWordHighBit() {
return (new RegNumber(getRegWordWidth())).getMinusOneHighestBit();
}
/** returns true if at least one category is set
* (should only be called in finishReg since field info will affect)
*/
public boolean hasCategory() {
return category.hasValue();
}
/** returns true if specified category string is set
* (should only be called in finishReg since field info will affect) */
public boolean hasCategory(String string) {
return category.hasValue(string);
}
/** get category (should only be called in finishReg since field info will affect)
* @return the category
*/
public JspecCategory getCategory() {
return category;
}
/** set category
* @param category the category to set
*/
public void setCategory(String category) {
this.category = new JspecCategory(category);
}
/** isAlias
* @return true if this reg instance is an alias
*/
public boolean isAlias() {
return ((getAliasedId() != null) && (getAliasedId().length() > 0)) ;
}
/** get aliasedId
* @return the aliasedId
*/
public String getAliasedId() {
return aliasedId;
}
/** set aliasedId
* @param aliasedId the aliasedId to set
*/
public void setAliasedId(String aliasedId) {
this.aliasedId = aliasedId;
}
/** get alais baseName
* @return alais the baseName
*/
public String getAliasBaseName() {
return getAliasInstancePath().replace('.', '_');
}
/** get instancePath of the Aliased register
* @return the aliasInstancePath
*/
public String getAliasInstancePath() {
// if alias string is absolute use it
if (getAliasedId().contains(".")) return getAliasedId();
// else a relative path so swap id
String retStr = getInstancePath();
retStr = retStr.replaceFirst(getId() + "$", getAliasedId());
return retStr;
}
/** get hasInterruptFields - return true if an intr field is contained in this reg
*/
public boolean hasInterruptFields() {
return hasInterruptFields;
}
/** set hasInterruptFields
*/
public void setHasInterruptFields(boolean hasInterruptFields) {
this.hasInterruptFields = hasInterruptFields;
}
/** get hasInterruptOutputDefined - output-specific status info
*/
public boolean hasInterruptOutputDefined() {
return hasInterruptOutputDefined;
}
/** set hasInterruptOutputDefined - output-specific status info
*/
public void setHasInterruptOutputDefined(boolean hasInterruptOutputDefined) {
this.hasInterruptOutputDefined = hasInterruptOutputDefined;
}
/** get hasHaltOutputDefined - output-specific status info
* @return the hasHaltOutputDefined
*/
public boolean hasHaltOutputDefined() {
return hasHaltOutputDefined;
}
/** set hasHaltOutputDefined - output-specific status info
* @param hasHalt the hasHalt to set
*/
public void setHasHaltOutputDefined(boolean hasHaltOutputDefined) {
this.hasHaltOutputDefined = hasHaltOutputDefined;
}
/** get isSwReadable (valid after fields processed)
* @return the isSwReadable
*/
public boolean isSwReadable() {
return isSwReadable;
}
/** set isSwReadable
* @param isSwReadable the isSwReadable to set
*/
public void setSwReadable(boolean isSwReadable) {
this.isSwReadable = isSwReadable;
}
/** get isSwWriteable (valid after fields processed)
* @return the isSwWriteable
*/
public boolean isSwWriteable() {
return isSwWriteable;
}
/** set isSwWriteable
* @param isSwWriteable the isSwWriteable to set
*/
public void setSwWriteable(boolean isSwWriteable) {
this.isSwWriteable = isSwWriteable;
}
/** get isMem
* @return the isMem
*/
public boolean isMem() {
return isMem;
}
/** return true if this register is to be pruned from c++ model output */
public boolean cppModPrune() {
return cppModPrune;
}
public void setCppModPrune(boolean cppModPrune) {
this.cppModPrune = cppModPrune;
}
/** set isMem
* @param isMem the isMem to set
*/
public void setMem(boolean isMem) {
this.isMem = isMem;
}
/** return true if register contains fields with dont_test set
* @return true if has dont_test fields
*
public boolean hasDontTestFields() {
RegNumber dontTestMask = getDontTestMask();
return (dontTestMask.isNonZero());
}*/
// ------------------- internal reg signals -------------------------
/** get jspecAttributes
* @return the jspecAttributes
*/
public String getJspecAttributes() {
return jspecAttributes;
}
/** set jspecAttributes
* @param jspecAttributes the jspecAttributes to set
*/
public void setJspecAttributes(String jspecAttributes) {
this.jspecAttributes = jspecAttributes;
}
/** return the logic module input name for register */
public String getDecodeToLogicName() {
return "d2l_" + getBaseName() + "_w" ;
}
/** return the logic module input name for register */
public String getLogicToDecodeName() {
return "l2d_" + getBaseName() + "_r" ;
}
/** return the logic module write enable name for register */
public String getDecodeToLogicWeName() {
return "d2l_" + getBaseName() + "_we" ;
}
/** return the logic module read enable name for register */
public String getDecodeToLogicReName() {
return "d2l_" + getBaseName() + "_re" ;
}
// ------------------- external reg signals -------------------------
/** return the external reg write data name */
public String getDecodeToHwAddrName() {
return "d2h_" + getBaseName() + "_addr" ;
}
/** return the external reg write data name */
public String getDecodeToHwName() {
return "d2h_" + getBaseName() + "_w" ;
}
/** return the external reg transaction size name */
public String getDecodeToHwTransSizeName() {
return "d2h_" + getBaseName() + "_size" ;
}
/** return the external reg return transaction size name */
public String getHwToDecodeTransSizeName() {
return "h2d_" + getBaseName() + "_retsize" ;
}
/** return the external reg read data name */
public String getHwToDecodeName() {
return "h2d_" + getBaseName() + "_r" ;
}
/** return the external reg we name */
public String getDecodeToHwWeName() {
return "d2h_" + getBaseName() + "_we" ;
}
/** return the external reg re name */
public String getDecodeToHwReName() {
return "d2h_" + getBaseName() + "_re" ;
}
/** return the external reg ack name */
public String getHwToDecodeAckName() {
return "h2d_" + getBaseName() + "_ack" ;
}
/** return the external reg nack name */
public String getHwToDecodeNackName() {
return "h2d_" + getBaseName() + "_nack" ;
}
// --------------------
/** return the external reg interrupt output name
* @param addPrefix */
public static String getLogicToHwIntrName(String regPath, boolean addPrefix) {
String prefix = addPrefix ? "l2h_" : "";
return prefix + regPath + "_intr_o" ;
}
/** return the external reg halt output name */
public static String getLogicToHwHaltName(String regPath, boolean addPrefix) {
String prefix = addPrefix ? "l2h_" : "";
return prefix + regPath + "_halt_o" ;
}
/** return the external reg interrupt output name */
public String getLogicToHwIntrName() {
return getLogicToHwIntrName(getBaseName(), true);
}
/** return the external reg halt output name */
public String getLogicToHwHaltName() {
return getLogicToHwHaltName(getBaseName(), true);
}
// --------------------------------------------------------
/** get filledBits
* @return the filledBits
*/
public Integer getFilledBits() {
return filledBits;
}
/** get fieldCount
* @return the fieldCount
*/
public Integer getFieldCount() {
return fieldCount;
}
/** adjust offset for a new fieldset hierarchy
* @param newOffset - total fieldset offset from all fsets in hierarchy
* */
public void setFieldSetOffset(Integer newOffset) {
// adjust current offset
fieldSetOffset = newOffset;
//System.out.println("RegProperties setFieldSetOffset: offset=" + newOffset);
}
/** add a new field to this register based on next available bits
* @return the index to be used for field or null if no valid index */
public Integer addField(FieldProperties fieldProperties) {
// if field is an interrupt then mark this register
if (fieldProperties.isInterrupt()) setHasInterruptFields(true);
// compute field indices within register
Integer width = fieldProperties.getFieldWidth();
Integer offset = fieldProperties.getExtractInstance().getOffset(); // get the relative offset of this field
Integer bitPaddingOffset = ((ModRegister) getExtractInstance().getRegComp()).getPadBits();
//System.out.println("RegProperties addField: id=" + fieldProperties.getInstancePath() + ", offset=" + offset + ", width=" + width + ", fsetOffset=" + fieldSetOffset + ", bitPaddingOffset=" + bitPaddingOffset + ", regwidth=" + getRegWidth());
// compute the actual field index
Integer lowFieldIndex = 0;
if (offset != null) {
offset += fieldSetOffset; // explicit offset is supplied so add any fieldset offset
offset += bitPaddingOffset; // also add an offset if bit padding is needed TODO - this assumes padding is same dir as offset (pad from msb if pack from msb)
lowFieldIndex = addFixedField(offset, width); // explicit location used
}
else lowFieldIndex = addFloatingField(width);
// now create the output array index string
if (lowFieldIndex == null) {
Ordt.errorExit("Unable to fit all fields in register instance " + getId());
}
fieldCount++; // bump the field count
return lowFieldIndex;
}
/** verify that field at specified location can fit in register
* @return specified index of field or null if no suitable index found */
private Integer addFixedField(Integer offset, Integer width) {
// convert specified offset to an index value depending on direction
Integer lowIndex = fieldOffsetsFromZero ? offset : getRegWidth() - offset - width;
//System.out.println("RegProperties addFixedField id=" + getId() + ", rwidth=" + getRegWidth() + ", foffset=" + offset + ", fwidth=" + width + ", computed lowIndex=" + lowIndex);
// find next index that could fit this field
for (int idx=lowIndex; idx>=0; idx--) {
// if field fits update available and return lowIndex
if (availableBits[idx] >= width + (lowIndex - idx)) {
filledBits += width; // bump the filled bits count
// adjust available space above field
if (availableBits[idx] >= width + (lowIndex - idx))
availableBits[lowIndex+width] = availableBits[idx] - width - (lowIndex - idx);
availableBits[idx] = lowIndex - idx; // adjust avail space below field
return lowIndex;
}
}
return null;
}
/** find first available register index that can fit this width
* @return index of field or null if no suitable index found */
private Integer addFloatingField(Integer width) {
for (int idx=0; idx<getRegWidth(); idx++) {
// if space found then update the avail info and return the low index
if (availableBits[idx]>=width) {
filledBits += width; // bump the filled bits count
availableBits[idx+width] = availableBits[idx] - width; // change available space
availableBits[idx] = 0; // no longer space avialable here
return idx;
}
}
return null; // search failed so return null
}
/** true if register has unused bits
*/
public boolean hasNopBits() {
return getRegWidth() != filledBits;
}
/** return the array string for this register */
public String getRegArrayString() {
return " [" + (getRegWidth() - 1) + ":0] ";
}
/** return index range for a group of replicated external registers */
public String getExtAddressArrayString() {
if (getExtAddressWidth() > 1) return " [" + (getExtLowBit() + getExtAddressWidth() - 1) + ":" + getExtLowBit() + "] ";
else return "";
}
/** true if address size is same as reg size */
public boolean isSingleExtReg() {
return (isExternal() && (Utils.getBits(getRegWordWidth()) == getExtAddressWidth()));
}
}
| [
"snellenbach@yahoo.com"
] | snellenbach@yahoo.com |
185e8a60905b3338cbc1c7d0a952100018b8c2fc | c18183c57753d039b55ddae0fddce6fbb407d7cb | /OkhttpGetXML/app/src/androidTest/java/cn/dshitpie/okhttpgetxml/ExampleInstrumentedTest.java | 6cdcb766b96e07dde41f3e258183a713723dc1e2 | [
"MIT"
] | permissive | Autokaka/Android-Single-Ranking | 7cb8d0eec3426134027e48d5a089b8cbb1283b9f | 4f3907bc2a5159ba9256022dec422f1a2b334013 | refs/heads/master | 2020-04-29T09:53:19.741269 | 2019-07-22T10:48:51 | 2019-07-22T10:48:51 | 176,042,131 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 732 | java | package cn.dshitpie.okhttpgetxml;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("cn.dshitpie.okhttpgetxml", appContext.getPackageName());
}
}
| [
"qq1909698494@gmail.com"
] | qq1909698494@gmail.com |
3d68670bc6089935c62bdeb7400abc6a36e7c714 | 12b62a916d20609a05d554326e3aa386a141bfa0 | /app/src/main/java/com/kagu/mymonitoring/pic/MainActivityPic.java | cac8372f97e727d93397a94bab980beb163e395b | [] | no_license | NesyWidya24/MonitoringWGS | c28efea71621978cb7b881347c0f307ca2a6d280 | f46be3d5c4110be754b3c6cf49caa382a9fe246f | refs/heads/master | 2023-01-05T01:20:10.657592 | 2020-10-27T11:18:30 | 2020-10-27T11:18:30 | 302,835,085 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,165 | java | package com.kagu.mymonitoring.pic;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.iid.FirebaseInstanceId;
import com.kagu.mymonitoring.R;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.NavigationUI;
import java.util.HashMap;
public class MainActivityPic extends AppCompatActivity {
String myId;
FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_pic);
if (getSupportActionBar()!=null)
getSupportActionBar().hide();
firebaseAuth = FirebaseAuth.getInstance();
BottomNavigationView navView = findViewById(R.id.nav_view_pic);
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_pic);
NavigationUI.setupWithNavController(navView, navController);
checkUserStat();
}
private void checkOnlineStat(String status){
DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Users").child(myId);
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("onlineStat", status);
reference.updateChildren(hashMap);
}
@Override
protected void onPause() {
super.onPause();
String timestamp = String.valueOf(System.currentTimeMillis());
checkOnlineStat(timestamp);
}
@Override
protected void onResume() {
checkUserStat();
checkOnlineStat("online");
super.onResume();
}
private void checkUserStat() {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
myId = user.getUid();
SharedPreferences preferences = getSharedPreferences("SP_USER", MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("Current_USERID", myId);
editor.apply();
}
}
@Override
protected void onStart() {
checkUserStat();
super.onStart();
}
@Override
public void onBackPressed() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Apakah anda benar-benar ingin keluar?")
.setCancelable(false)
.setPositiveButton("Ya", (dialogInterface, i) -> {
onPause();
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}).setNegativeButton("Tidak", (dialogInterface, i) -> {
}).show();
}
}
| [
"nessywidya@gmail.com"
] | nessywidya@gmail.com |
7d34c32382c73c7fa77af0157e8ed2cbfa1bc73f | 80bd2f8f1d79eb2b9660d25412dee0f2eb941ad3 | /jgx-common/src/main/java/com/gluxen/jgx/util/StringUtil.java | e081e747b3923434fc029a93f9214dbe3057e540 | [] | no_license | xihashao/gluxen-jgx | 05562364f8e4e959350b34b706f8dec9d02800b0 | 44b8d279dd7100842a9e74f40118cec050f00fb2 | refs/heads/master | 2021-01-01T17:54:10.224964 | 2017-07-24T13:30:36 | 2017-07-24T13:30:36 | 98,193,826 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 35,749 | java | package com.gluxen.jgx.util;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.Clob;
import java.util.*;
import java.util.regex.Pattern;
/**
*
* 字符串处理类
* @author lishiqiang
* @date 2017-3-15
* modify history
*/
public class StringUtil {
private static String string_gbk = "GBK";
private static final char[] digits = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z' };
public static final String getGBString(String str) {
String str2 = "";
try {
str2 = new String(str.getBytes("iso-8859-1"), string_gbk);
} catch (Exception e) {
e.printStackTrace();
str2 = "";
}
return str2;
}
public static String getNullString(HashMap hm, String hname)
throws Exception {
if (hm == null)
throw new Exception("Input HashMap is null");
if ((hm.get(hname) == null) || (" ".equals(hm.get(hname))))
return "";
return ((String) hm.get(hname.toUpperCase()));
}
public static String getNullString(Object o, String replace) {
return getNullString(o, " ", replace);
}
public static String getNullString(Object o, String nullString,
String replace) {
if (o == null)
return replace;
if (("".equals(o)) || (nullString.equals(o)))
return replace;
return o.toString();
}
public static String getNullString(Object str, int len) {
return getNullString(str, len, "");
}
public static String getHtmlShow(Object str, int len, String replacestr) {
if (str == null)
return replacestr;
String str1 = (String) str;
int strlen = str1.length();
if (strlen >= len)
return str1.substring(0, len) + "...";
return str1;
}
public static String getNullString(Object str, int len, String replacestr) {
if (str == null)
return replacestr;
String str1 = (String) str;
int strlen = str1.length();
if (strlen >= len)
return str1.substring(0, len);
return str1;
}
public static int getNullInt(Object str, int defaultint) {
int a;
try {
a = Integer.parseInt((String) str);
return a;
} catch (NumberFormatException e) {
}
return defaultint;
}
public static String getRight(String str, int len) {
if (str == null)
return null;
int strlen = str.length();
if (len < strlen)
return str.substring(strlen - len, strlen);
return str;
}
public static String getRight(String str, int len, String rep)
throws Exception {
if (str == null)
return null;
int strlen = str.length();
if (len < strlen)
return str.substring(strlen - len, strlen);
if (rep == null)
throw new Exception("SU001: replace string is null !!");
StringBuffer str1 = new StringBuffer();
for (; strlen < len; ++strlen)
str1.append(rep);
str1.append(str);
return str1.toString();
}
public static String repSQLChar(String s) {
if (s == null)
return "";
return s.replace('\'', ' ');
}
public static String getCurrClassPath() {
String str = "";
try {
str = StringUtil.class.getProtectionDomain().getCodeSource()
.toString();
str = str.substring(str.indexOf("/"), str.lastIndexOf("/"));
} catch (Exception ex) {
return null;
}
return str;
}
public static String getClearCommaStr(String str) {
if (str == null) {
return "";
}
if (str.lastIndexOf(",") != -1)
str = str.substring(0, str.lastIndexOf(","));
return str;
}
public static String SQLnullString(String sv) {
if (sv == null)
return " ";
sv.replaceAll("'", " ");
return sv;
}
public static String StringBlank(String blank) {
char c;
if (blank == null)
return " ";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < blank.length(); ++i) {
c = blank.charAt(i);
switch (c) {
case ' ':
sb.append(' ');
break;
default:
sb.append(c);
}
}
return sb.toString();
}
public static String StringBlankAll(String blank) {
if (blank == null)
return "";
blank = StringBlank(blank);
return blank.trim();
}
public static String SQLnullInt(String sv) {
if (sv == null)
return "0";
return sv;
}
public static String SQLnullDate(String sv) {
if (sv == null)
return "1900-1-1";
return sv;
}
public static boolean isNull(String str) {
return ((str == null) || (str.length() == 0));
}
public static boolean isNotNull(String str) {
return (!(isNull(str)));
}
public static boolean isEquals(String str1, String str2) {
return str1.equalsIgnoreCase(str2);
}
public static String replace(String mainString, String oldString,
String newString) {
if (mainString == null)
return null;
if ((oldString == null) || (oldString.length() == 0))
return mainString;
if (newString == null) {
newString = "";
}
int i = mainString.lastIndexOf(oldString);
if (i < 0) {
return mainString;
}
StringBuffer mainSb = new StringBuffer(mainString);
while (i >= 0) {
mainSb.replace(i, i + oldString.length(), newString);
i = mainString.lastIndexOf(oldString, i - 1);
}
return mainSb.toString();
}
public static String replaceFirst(String mainString, String oldString,
String newString) {
if (mainString == null)
return null;
if ((oldString == null) || (oldString.length() == 0))
return mainString;
if (newString == null) {
newString = "";
}
int i = mainString.lastIndexOf(oldString);
if (i < 0) {
return mainString;
}
StringBuffer mainSb = new StringBuffer(mainString);
if (i >= 0)
mainSb.replace(i, i + oldString.length(), newString);
return mainSb.toString();
}
public static String join(List list, String delim) {
if ((list == null) || (list.size() < 1))
return null;
StringBuffer buf = new StringBuffer();
Iterator i = list.iterator();
while (i.hasNext()) {
buf.append((String) i.next());
if (i.hasNext())
buf.append(delim);
}
return buf.toString();
}
public static List splitList(String str, String delim) {
List splitList = null;
StringTokenizer st = null;
if (str == null) {
return splitList;
}
if (delim != null)
st = new StringTokenizer(str, delim);
else
st = new StringTokenizer(str);
if ((st != null) && (st.hasMoreTokens())) {
splitList = new ArrayList();
while (st.hasMoreTokens())
splitList.add(st.nextToken());
}
return splitList;
}
public static String[] split(String source, char delim) {
return split(source, String.valueOf(delim));
}
public static String[] split(String source) {
return split(source, ",");
}
public static int[] splitInt(String source) {
return splitInt(source, ",");
}
public static int[] splitInt(String source, String type) {
String[] s = split(source, type);
return getInt(s);
}
public static int[] getInt(String[] s) {
int[] i = new int[s.length];
for (int m = 0; m < s.length; ++m)
i[m] = getInt(s[m], 0);
return i;
}
public static String ChangeToInsqlType(String source, String delim) {
String s = "";
String[] l = split(source, delim);
for (int k = 0; k < l.length; ++k) {
s = s + "'" + l[k] + "'";
if (k != l.length - 1)
s = s + ",";
}
return s;
}
public static Map strToMap(String str) {
if (str == null)
return null;
Map decodedMap = new HashMap();
List elements = splitList(str, "?");
Iterator i = elements.iterator();
while (i.hasNext()) {
String s = (String) i.next();
List e = splitList(s, "=");
if (e.size() != 2)
continue;
String name = (String) e.get(0);
String value = (String) e.get(1);
decodedMap.put(URLDecoder.decode(name), URLDecoder.decode(value));
}
return decodedMap;
}
public static String mapToStr(Map map) {
if (map == null)
return null;
StringBuffer buf = new StringBuffer();
Set keySet = map.keySet();
Iterator i = keySet.iterator();
boolean first = true;
while (i.hasNext()) {
Object key = i.next();
Object value = map.get(key);
if (key instanceof String) {
if (!(value instanceof String))
continue;
String encodedName = URLEncoder.encode((String) key);
String encodedValue = URLEncoder.encode((String) value);
if (first)
first = false;
else
buf.append("?");
buf.append(encodedName);
buf.append("=");
buf.append(encodedValue);
}
}
return buf.toString();
}
public static String removeSpaces(String str) {
StringBuffer newString = new StringBuffer();
for (int i = 0; i < str.length(); ++i)
if (str.charAt(i) != ' ')
newString.append(str.charAt(i));
return newString.toString();
}
public static boolean contains(String MainString, String containedString) {
int i = MainString.indexOf(containedString);
return (i != -1);
}
public static int contains(String[] mainStrings, String containedString,
boolean caseSensitive) {
for (int i = 0; i < mainStrings.length; ++i) {
if (caseSensitive) {
if (!(mainStrings[i].equals(containedString)))
continue;
return i;
}
if (mainStrings[i].equalsIgnoreCase(containedString))
return i;
}
return -1;
}
public static String getString(String srcString, String key, int length,
String postfix) {
if ((srcString == null) || (srcString.trim().length() == 0))
return "";
String returnStr = "";
int index = srcString.indexOf(key);
if (index > 0) {
returnStr = srcString.substring(0, index) + postfix;
} else if (srcString.length() > length)
returnStr = srcString.substring(0, length) + postfix;
else {
returnStr = srcString;
}
returnStr = returnStr.replaceAll("<P>", "");
returnStr = returnStr.replaceAll("<p>", "");
returnStr = returnStr.replaceAll("</P>", "");
returnStr = returnStr.replaceAll("</p>", "");
returnStr = returnStr.replaceAll("<BR>", "");
returnStr = returnStr.replaceAll("<br>", "");
return returnStr;
}
public static int contains(String[] mainStrings, String containedString) {
return contains(mainStrings, containedString, true);
}
public static int containsIgnoreCase(String[] mainStrings,
String containedString) {
return contains(mainStrings, containedString, false);
}
public static String getRandomString(int length) {
String strRnd = "";
for (int i = 0; i < length; ++i) {
int temp = new Double(Math.random() * 997.0D).intValue()
% digits.length;
strRnd = strRnd + String.valueOf(digits[temp]);
}
return strRnd;
}
public static String toChinese(String str) {
try {
if (str == null)
return null;
str = new String(str.getBytes("ISO8859_1"), "GBK");
return str;
} catch (Exception e) {
System.err.println(e.getMessage());
}
return null;
}
public static String toUTF(String str) {
try {
if (str == null)
return null;
str = new String(str.getBytes("GB2312"), "utf-8");
return str;
} catch (Exception e) {
System.err.println(e.getMessage());
}
return null;
}
public static String toUtf8String(String s) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); ++i) {
char c = s.charAt(i);
if ((c >= 0) && (c <= 255)) {
sb.append(c);
} else {
byte[] b;
try {
b = Character.toString(c).getBytes("utf-8");
} catch (Exception ex) {
b = new byte[0];
}
for (int j = 0; j < b.length; ++j) {
int k = b[j];
if (k < 0)
k += 256;
sb.append("%" + Integer.toHexString(k).toUpperCase());
}
}
}
return sb.toString();
}
public static String UnicodeToGB(String strIn) {
String strOut = null;
if ((strIn == null) || (strIn.trim().equals("")))
return strIn;
try {
byte[] b = strIn.getBytes("GB2312");
strOut = new String(b, "ISO8859_1");
} catch (Exception e) {
System.out.println("unicodeToGB exception : " + e.getMessage()
+ "\n");
}
return strOut;
}
public static String GBToUnicode(String strIn) {
String strOut = null;
if ((strIn == null) || (strIn.trim().equals("")))
return strIn;
try {
byte[] b = strIn.getBytes("ISO8859_1");
strOut = new String(b, "GB2312");
} catch (Exception e) {
System.out.println("GBToUnicode exception : " + e.getMessage()
+ "\n");
}
return strOut;
}
public static String transCode(String value, String enc) {
try {
if (value == null)
return null;
value = value.trim();
value = new String(value.getBytes("ISO8859_1"), enc);
return value;
} catch (Exception e) {
}
return null;
}
public static String toChineseNumber(String number) {
String[] num = { };
String[] unt = { };
String value = "";
int i = 0;
for (int j = number.length(); i < number.length();) {
value = value
+ num[Integer.parseInt(String.valueOf(number.charAt(i)))]
+ unt[j];
--j;
++i;
}
value = value + number.substring(number.length());
if ((value.substring(0, 1) == "һ") && (value.length() == 3))
value = value.substring(1, value.length());
return value;
}
public static String toChineseNumber(int number) {
return toChineseNumber(String.valueOf(number));
}
public static void printStrings(String[] strings, String delim,
OutputStream out) {
try {
if (strings != null) {
int length = strings.length - 1;
for (int i = 0; i < length; i++) {
if (strings[i] != null) {
if (strings[i].indexOf(delim) > -1) {
out.write(("\"" + strings[i] + "\"" + delim)
.getBytes());
} else {
out.write((strings[i] + delim).getBytes());
}
} else {
out.write("null".getBytes());
}
}
if (strings[length] != null) {
if (strings[length].indexOf(delim) > -1) {
out.write(("\"" + strings[length] + "\"").getBytes());
} else {
out.write(strings[length].getBytes());
}
} else {
out.write("null".getBytes());
}
} else {
out.write("null".getBytes());
}
} catch (IOException e) {
}
}
public static void printStrings(String[] strings, String delim) {
printStrings(strings, delim, System.out);
}
public static void printStrings(String[] strings, OutputStream out) {
printStrings(strings, ",", out);
}
public static void printStrings(String[] strings) {
printStrings(strings, ",", System.out);
}
public static int getStringLength(String str) {
return str.length();
}
public static String getString(String str) {
if (str == null)
return "";
return str;
}
public static String getString(String str, String defValue) {
if ((str == null) || ("".equals(str)) || ("null".equals(str))
|| ("NULL".equals(str)))
return defValue;
return str;
}
public static String getString(Map m, String para) {
return getString(m.get(para.toUpperCase()), "");
}
public static String getString(Map m, String para, String def) {
return getString(m.get(para.toUpperCase()), def);
}
public static String getString1(Map m, String para, String def) {
if (m == null)
return def;
return getString(m.get(para), def);
}
public static String getString(Object str, String defValue) {
return getString(String.valueOf(str), defValue);
}
public static String substring(String str, int count1) {
int count = count1 / 2;
if (str == null)
return "";
if (str.length() <= count)
return str;
return str.substring(0, count) + "..";
}
public static String[] split(String source, String delim) {
String[] wordLists;
if (source == null) {
wordLists = new String[1];
wordLists[0] = source;
return wordLists;
}
if (delim == null) {
delim = ",";
}
StringTokenizer st = new StringTokenizer(source, delim);
int total = st.countTokens();
wordLists = new String[total];
for (int i = 0; i < total; i++) {
wordLists[i] = st.nextToken();
}
return wordLists;
}
public static String substringWithAuthor(String str, int count1,
String author) {
int count = count1 / 2;
if (str == null)
return "";
String s = str + "(" + author + ")";
if (s.length() <= count)
return str + "(" + author + ")";
return str.substring(0, count) + "(" + author + ")..";
}
public static String substringstr(String str, int count1) {
int count = count1 / 2;
if (str == null)
return "";
if (str.length() <= count)
return str;
return str.substring(0, count);
}
public static int getInt(String str, int defaultValue) {
int returnInt = defaultValue;
try {
returnInt = Integer.parseInt(str);
} catch (Exception e) {
returnInt = defaultValue;
}
return returnInt;
}
public static long getLong(String str, long defaultValue) {
long returnInt = defaultValue;
try {
returnInt = Long.parseLong(str);
} catch (Exception e) {
returnInt = defaultValue;
}
return returnInt;
}
public static double getDouble(String str, double defaultValue) {
double returnInt = defaultValue;
try {
returnInt = Double.parseDouble(str);
} catch (Exception e) {
returnInt = defaultValue;
}
return returnInt;
}
public static boolean isBeginWith(String sourceString, String keyString) {
int index = sourceString.indexOf(keyString);
return (index == 0);
}
public static boolean isEndWith(String sourceString, String keyString) {
int index = sourceString.lastIndexOf(keyString);
return (index == sourceString.length() - keyString.length());
}
public static String getFileSize(int fileSize) {
return getFileSize(fileSize);
}
public static String getFileSize(long fileSize) {
String reStr = "";
long Imb = 7005603615582715904L;
long temp = 7005603615582715904L;
long Ikb = 7005603615582715904L;
long Ib = 7005603615582715904L;
if (fileSize > 1073741824L) {
long Igb = fileSize / 1073741824L;
temp = fileSize % 1073741824L * 100L / 1073741824L;
reStr = Igb + "." + temp + "GB";
} else if (fileSize > 1048576L) {
Imb = fileSize / 1048576L;
temp = fileSize % 1048576L * 100L / 1048576L;
reStr = Imb + "." + temp + "MB";
} else if (fileSize > 1024L) {
Ikb = fileSize / 1024L;
reStr = Ikb + "KB";
} else {
Ib = fileSize;
reStr = Ib + " ";
}
return reStr;
}
public static String getLastIndexOfString(String source, String key) {
int k = source.lastIndexOf(key);
return source.substring(k + 1, source.length());
}
public static String AppendStr(String str1, String str2, int count,
boolean right) {
String newStr = "";
for (int i = 0; i < count - str1.length(); ++i)
newStr = newStr + str2;
if (right)
return str1 + newStr;
return newStr + str1;
}
public static String getReplaceString(String source, String[] values) {
return getReplaceString("%", source, values);
}
public static String getReplaceString(String prefix, String source,
String[] values) {
String result = source;
if ((source == null) || (values == null) || (values.length < 1))
return source;
if (prefix == null) {
prefix = "%";
}
for (int i = 0; i < values.length; ++i) {
String argument = prefix + Integer.toString(i + 1);
int index = result.indexOf(argument);
if (index != -1) {
String temp = result.substring(0, index);
if (i < values.length)
temp = temp + values[i];
else
temp = temp + values[(values.length - 1)];
temp = temp + result.substring(index + 2);
result = temp;
}
}
return result;
}
public static String filterStackTrace(Throwable e, String[] filterPackages)
throws IOException {
String s1;
if (e == null)
return "No exception founded";
StringWriter expout = new StringWriter();
StringBuffer out = new StringBuffer();
e.printStackTrace(new PrintWriter(expout));
BufferedReader br = new BufferedReader(new StringReader(expout
.toString()));
while ((s1 = br.readLine()) != null) {
boolean f = false;
for (int i = 0; i < filterPackages.length; ++i) {
if (s1.indexOf(filterPackages[i]) == -1)
continue;
f = true;
break;
}
if (!(f)) {
out.append(s1);
out.append("\n");
}
}
return out.toString();
}
public static String toString(String[] main, String s) {
if ((main == null) || (main.length == 0))
return "";
String returnStr = s;
for (int i = 0; i < main.length; ++i)
returnStr = returnStr + main[i] + s;
return returnStr;
}
public static String trim(String s) {
if (s == null)
s = "";
return s.trim();
}
public static String trimBeginEnd(String str, String ts) {
if (str == null)
return "";
do
str = str.substring(ts.length(), str.length());
while (str.startsWith(ts));
for (; str.endsWith(ts); str = str.substring(0, str.length()
- ts.length()))
;
return str;
}
public static String trimBeginEndBlank(String s) {
if (s == null)
return "";
s = s.trim();
s = trimBeginEnd(s, " ");
s = trimBeginEnd(s, " ");
return s;
}
public static String convertEncoding(String source, String sencoding,
String dencoding) {
if (sencoding == null)
sencoding = "gb2312";
if (sencoding.equals(dencoding))
return source;
try {
return new String(source.getBytes(sencoding), dencoding);
} catch (UnsupportedEncodingException ex) {
}
return source;
}
public static String CLobToStr(Clob clob) throws Exception {
String strContent = "";
if (clob != null) {
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
for (String s = br.readLine(); s != null; s = br.readLine())
strContent = strContent + s + "\r\n";
}
return strContent;
}
public static String CLobToString(Clob clob) throws Exception {
String strContent = "";
if (clob != null) {
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
for (String s = br.readLine(); s != null; s = br.readLine())
strContent = strContent + s;
}
return strContent;
}
/**
* 把输入的金额转换为汉语中人民币的大写
*
* @param numberOfMoney
* 输入的金额
* @return 对应的汉语大写
*/
public static String number2CNMontrayUnit(BigDecimal numberOfMoney) {
String[] CN_UPPER_NUMBER = { "零", "壹", "贰", "叁", "肆",
"伍", "陆", "柒", "捌", "玖" };
/**
* 汉语中货币单位大写,这样的设计类似于占位符
*/
String[] CN_UPPER_MONETRAY_UNIT = { "分", "角", "元",
"拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾",
"佰", "仟" };
/**
* 特殊字符:整
*/
String CN_FULL = "整";
/**
* 特殊字符:负
*/
String CN_NEGATIVE = "负";
/**
* 金额的精度,默认值为2
*/
int MONEY_PRECISION = 2;
/**
* 特殊字符:零元整
*/
String CN_ZEOR_FULL = "零元" + CN_FULL;
StringBuffer sb = new StringBuffer();
// -1, 0, or 1 as the value of this BigDecimal is negative, zero, or
// positive.
int signum = numberOfMoney.signum();
// 零元整的情况
if (signum == 0) {
return CN_ZEOR_FULL;
}
//这里会进行金额的四舍五入
long number = numberOfMoney.movePointRight(MONEY_PRECISION)
.setScale(0, 4).abs().longValue();
// 得到小数点后两位值
long scale = number % 100;
int numUnit = 0;
int numIndex = 0;
boolean getZero = false;
// 判断最后两位数,一共有四中情况:00 = 0, 01 = 1, 10, 11
if (!(scale > 0)) {
numIndex = 2;
number = number / 100;
getZero = true;
}
if ((scale > 0) && (!(scale % 10 > 0))) {
numIndex = 1;
number = number / 10;
getZero = true;
}
int zeroSize = 0;
while (true) {
if (number <= 0) {
break;
}
// 每次获取到最后一个数
numUnit = (int) (number % 10);
if (numUnit > 0) {
if ((numIndex == 9) && (zeroSize >= 3)) {
sb.insert(0, CN_UPPER_MONETRAY_UNIT[6]);
}
if ((numIndex == 13) && (zeroSize >= 3)) {
sb.insert(0, CN_UPPER_MONETRAY_UNIT[10]);
}
sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);
sb.insert(0, CN_UPPER_NUMBER[numUnit]);
getZero = false;
zeroSize = 0;
} else {
++zeroSize;
if (!(getZero)) {
sb.insert(0, CN_UPPER_NUMBER[numUnit]);
}
if (numIndex == 2) {
if (number > 0) {
sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);
}
} else if (((numIndex - 2) % 4 == 0) && (number % 1000 > 0)) {
sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);
}
getZero = true;
}
// 让number每次都去掉最后一个数
number = number / 10;
++numIndex;
}
// 如果signum == -1,则说明输入的数字为负数,就在最前面追加特殊字符:负
if (signum == -1) {
sb.insert(0, CN_NEGATIVE);
}
// 输入的数字小数点后两位为"00"的情况,则要在最后追加特殊字符:整
if (!(scale > 0)) {
sb.append(CN_FULL);
}
return sb.toString();
}
public static final String COLON = ":";
public static final String COMMA = ",";
public static final String EMPTY = "";
public static final String UNDER_LINE = "_";
public static final String ENDL = "\n";
public static final String SLASH = "/";
public static final String BLANK = " ";
public static final String DOT = ".";
public static final String FILE_SEPARATOR = File.separator;
public static String encodePassword(String paramString)
{
String str = null;
try
{
str = encodePassword(paramString, "MD5");
}
catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
{
localNoSuchAlgorithmException.printStackTrace();
}
return str;
}
public static String changeList2String(List<String> paramList)
{
String str = paramList.toString();
return str.substring(1, str.length() - 1);
}
public static boolean isBlank(String paramString)
{
int i = 0;
if ((paramString == null) || ("".equals(paramString.trim())))
i = 1;
if(i==1)
{
return true;
}else return false;
}
public static boolean isNotBlank(String paramString)
{
int i = 0;
if ((paramString != null) && (!("".equals(paramString))))
i = 1;
if(i==1)
{
return true;
}else return false;
}
public static String encodePassword(String paramString1, String paramString2)
throws NoSuchAlgorithmException
{
byte[] arrayOfByte1 = paramString1.getBytes();
MessageDigest localMessageDigest = null;
localMessageDigest = MessageDigest.getInstance(paramString2);
localMessageDigest.reset();
localMessageDigest.update(arrayOfByte1);
byte[] arrayOfByte2 = localMessageDigest.digest();
StringBuffer localStringBuffer = new StringBuffer();
for (int i = 0; i < arrayOfByte2.length; ++i)
{
if ((arrayOfByte2[i] & 0xFF) < 16)
localStringBuffer.append("0");
localStringBuffer.append(Long.toString(arrayOfByte2[i] & 0xFF, 16));
}
return localStringBuffer.toString();
}
public static boolean isEmpty(Object s){
return s == null || s.toString().trim().length() == 0 || s.toString().trim().equalsIgnoreCase("null");
}
public static String base64Encode(String paramString)
{
BASE64Encoder localBASE64Encoder = new BASE64Encoder();
return localBASE64Encoder.encodeBuffer(paramString.getBytes()).trim();
}
public static String base64Decode(String paramString)
{
BASE64Decoder localBASE64Decoder = new BASE64Decoder();
try
{
return new String(localBASE64Decoder.decodeBuffer(paramString));
}
catch (IOException localIOException)
{
throw new RuntimeException(localIOException.getMessage(), localIOException.getCause());
}
}
public static String ljustZero(String paramString, int paramInt)
{
String str = "";
for (int i = 0; i < paramInt - paramString.length(); ++i)
str = str + "0";
str = str + paramString;
return str;
}
public static int getWordLength(String paramString)
{
int i = 0;
if (isBlank(paramString))
return i;
char[] arrayOfChar = paramString.toCharArray();
for (int j = 0; j < arrayOfChar.length; ++j)
if (isChinese(arrayOfChar[j]))
i += 2;
else
i += 1;
return i;
}
public static String getWord(String paramString, int paramInt)
{
char[] arrayOfChar = paramString.toCharArray();
StringBuffer localStringBuffer = new StringBuffer();
int i = 0;
for (int j = 0; j < arrayOfChar.length; ++j)
{
if (isChinese(arrayOfChar[j]))
i += 2;
else
i += 1;
if (i > paramInt)
break;
localStringBuffer.append(arrayOfChar[j]);
}
return localStringBuffer.toString();
}
public static boolean hasChinese(String paramString)
{
if (paramString == null)
return true;
char[] arrayOfChar = paramString.toCharArray();
for (int i = 0; i < arrayOfChar.length; ++i)
if (isChinese(arrayOfChar[i]))
return true;
return false;
}
public static boolean isChinese(char paramChar)
{
Character.UnicodeBlock localUnicodeBlock = Character.UnicodeBlock.of(paramChar);
return ((localUnicodeBlock != Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS) && (localUnicodeBlock != Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS) && (localUnicodeBlock != Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A) && (localUnicodeBlock != Character.UnicodeBlock.GENERAL_PUNCTUATION) && (localUnicodeBlock != Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION) && (localUnicodeBlock != Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS));
}
public static String[] splitIntoArr(String paramString)
{
if (isEmpty(paramString))
return new String[0];
return paramString.split(",");
}
public static String join(String[] paramArrayOfString)
{
return join(paramArrayOfString, ",", "'");
}
public static String join(String[] paramArrayOfString, String paramString)
{
return join(paramArrayOfString, ",", "");
}
public static String join(String[] paramArrayOfString, String paramString1, String paramString2)
{
String str = "";
for (int i = 0; i < paramArrayOfString.length; ++i)
{
str = str + paramString2 + paramArrayOfString[i] + paramString2;
if (i == paramArrayOfString.length - 1)
continue;
str = str + paramString1;
}
return str;
}
public static String convertCode(String paramString1, String paramString2, String paramString3)
{
try
{
if (paramString1 == null)
return null;
if (paramString1.equals(""))
return "";
return new String(paramString1.getBytes(paramString2), paramString3);
}
catch (Exception localException)
{
return localException.toString();
}
}
public static boolean isUpperCase(String paramString)
{
int i = 1;
for (int k = 0; k < paramString.length(); ++k)
{
int j = paramString.charAt(k);
if ((j >= 65) && (j <= 90))
continue;
i = 0;
}
if(i==1)
{
return true;
}else return false;
}
public static boolean isLowerCase(String paramString)
{
int i = 1;
for (int k = 0; k < paramString.length(); ++k)
{
int j = paramString.charAt(k);
if ((j >= 97) && (j <= 122))
continue;
i = 0;
}
if(i==1)
{
return true;
}else return false;
}
public static String null2String(Object s)
{
return s == null ? "" : s.toString();
}
public static Integer null2Integer0(Object o)
{
if(o!=null){
String str=o.toString().trim();
return ("null".equalsIgnoreCase(str)||str.length()==0) ? Integer.valueOf(0) : Integer.valueOf(str);
} else return Integer.valueOf(0) ;
}
public static Long null2Long0(Object o)
{
if(o!=null){
String str=o.toString().trim();
return ("null".equalsIgnoreCase(str)||str.length()==0) ? Long.valueOf(0) : Long.valueOf(str);
} else return Long.valueOf(0) ;
}
public static double null2Double0(Object o)
{
if(o!=null){
String str=o.toString().trim();
return ("null".equalsIgnoreCase(str)||str.length()==0) ? Double.valueOf(0) : Double.valueOf(str);
} else return Long.valueOf(0) ;
}
public static double round(double v,int scale)
{
if(scale<0){
throw new IllegalArgumentException("The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = new BigDecimal("1");
return b.divide(one,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static final String replaceAll(String src, String fnd, String rep) {
if (src == null || src.equals("")) {
return "";
}
String dst = src;
int idx = dst.indexOf(fnd);
while (idx >= 0) {
dst = dst.substring(0, idx) + rep
+ dst.substring(idx + fnd.length(), dst.length());
idx = dst.indexOf(fnd, idx + rep.length());
}
return dst;
}
/**
* 文本转html
*
* @param txt
* @return
*/
public static String txt2htm(String txt) {
if (org.apache.commons.lang.StringUtils.isBlank(txt)) {
return txt;
}
StringBuilder sb = new StringBuilder((int) (txt.length() * 1.2));
char c;
for (int i = 0; i < txt.length(); i++) {
c = txt.charAt(i);
switch (c) {
case '&':
sb.append("&");
break;
case '<':
sb.append("<");
break;
case '>':
sb.append(">");
break;
case '"':
sb.append(""");
break;
case ' ':
sb.append(" ");
break;
case '\n':
sb.append("<br/>");
break;
default:
sb.append(c);
break;
}
}
return sb.toString();
}
/**
* html转文本
*
* @param htm
* @return
*/
public static String htm2txt(String htm) {
if (htm == null) {
return htm;
}
htm = htm.replace("&", "&");
htm = htm.replace("<", "<");
htm = htm.replace(">", ">");
htm = htm.replace(""", "\"");
htm = htm.replace(" ", " ");
htm = htm.replace("<br/>", "\n");
return htm;
}
public static String removeSqlComment(String sqlText){
Pattern p = Pattern.compile("(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/");
String presult = p.matcher(sqlText).replaceAll("$1");
return presult;
}
} | [
"xihashao@icloud.com"
] | xihashao@icloud.com |
75ff15aaa7650fbb2529edd8de0fa169df351ae6 | d6acef6a13fdf85bc84ba893f639c52bbf4462c0 | /src/main/java/seedu/duck/storage/Encoder.java | 2f8782c928ecafda84ddaf189b15b04aa1419e4f | [] | no_license | wangqinNick/ip | 053c3526a1c701cf708456e95094517058066ce6 | 62f58d0e6d3214bbb2b9f0629c32c58bd3668413 | refs/heads/master | 2022-12-18T15:19:06.862261 | 2020-10-01T01:53:37 | 2020-10-01T01:53:37 | 290,249,066 | 1 | 0 | null | 2020-09-19T15:26:25 | 2020-08-25T15:14:16 | Java | UTF-8 | Java | false | false | 202 | java | package seedu.duck.storage;
public class Encoder {
public static String encode(String username, String password){
return username +
"\n" +
password;
}
}
| [
"347656409nick@gmail.com"
] | 347656409nick@gmail.com |
0d92f6e3184514879dfaaf292405a3d7004131c4 | 990d19918ffaf9dace9bec1db2f99d39f65cf6f9 | /src/main/java/net/plazmix/core/api/spigot/util/Tile.java | 5c34595ae316d9a3606fbe0ca9720e52745e8453 | [] | no_license | plazmix-network/core-api | e36a07538fc01e4c158e77cc85ce29309397a79b | 9dac6bbeee336d3ece66cda48dc81fcaa7cdad0c | refs/heads/main | 2023-03-02T05:59:13.191707 | 2021-02-04T17:57:32 | 2021-02-04T17:57:32 | 331,713,036 | 0 | 1 | null | 2021-02-04T17:57:33 | 2021-01-21T18:10:13 | Java | UTF-8 | Java | false | false | 2,356 | java | package net.plazmix.core.api.spigot.util;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.bukkit.Location;
public final class Tile {
public static Tile fromString(String string) {
String[] data = string.split(":");
String[] coords = data[1].split(";");
return new Tile(data[0], Double.parseDouble(coords[0]), Double.parseDouble(coords[1]));
}
public static String toString(Tile position) {
return position.toString();
}
private final String world;
private final double x, z;
public Tile(Location location) {
this(location.getWorld().getName(), location.getX(), location.getZ());
}
public Tile(String world, double x, double z) {
this.world = world;
this.x = x;
this.z = z;
}
public String getWorld() {
return world;
}
public double getX() {
return x;
}
public double getZ() {
return z;
}
public int getBlockX() {
return (int) Math.floor(x);
}
public int getBlockZ() {
return (int) Math.floor(z);
}
public Tile add(UnaryDirection direction, double add) {
double x = 0, z = 0;
switch (direction) {
case NORTH:
z -= add;
break;
case WEST:
x -= add;
break;
case SOUTH:
z += add;
break;
case EAST:
x += add;
break;
default:
break;
}
return add(x, z);
}
public Tile add(double x, double z) {
return new Tile(world, this.x + x, this.z + z);
}
@Override
public String toString() {
return world + ":" + x + ";" + z;
}
@Override
public boolean equals(Object obj) {
if (obj == this)
return true;
if (obj == null || !(obj instanceof Tile))
return false;
Tile point = (Tile) obj;
return this.world.equals(point.world) && this.x == point.x && this.z == point.z;
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(world).append(x).append(z).toHashCode();
}
}
| [
"noreply@github.com"
] | plazmix-network.noreply@github.com |
a2bb0090b4442a62c2210790d75118c85883cf1c | 6bf27963f6417c46e6003e33195880ffb9b18024 | /src/Durga/Stream1.java | 15f0ea33acd057ca9ad679cd07395126aa7f3bd0 | [] | no_license | Vjy123/JavaCollections | f4a450338c5314663b3b34323727c9719fcb58fd | 5975494a7140c94a096d2506d279ad7051426224 | refs/heads/master | 2023-08-14T21:34:04.680798 | 2021-09-11T19:19:44 | 2021-09-11T19:19:44 | 405,463,983 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 592 | java | package Durga;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Stream1 {
public static void main(String[] args)
{
ArrayList<Integer>al=new ArrayList<>();
al.add(1);
al.add(10);
al.add(20);
al.add(30);
al.add(35);
al.add(40);
int sum=0;
for(Integer i:al)
{
if(i%2==0)
{
sum=sum+1;
}
System.out.println(i);
System.out.println(i+5);
}
//List<Integer>l=al.stream().filter(i->i%2==0).map(i->i+5).collect(Collectors.toList());
//System.out.println(l);
}
}
| [
"Vjy123"
] | Vjy123 |
e424b0956e211e183094387c4e867541cd3380f0 | 2d5dca4b2b978d2ecc1cefddc0f145f622ba1826 | /src/main/java/com/model/enums/TransactionStatus.java | f11a92e481b3ae09dbe443ac5151b049f444ef55 | [] | no_license | edvmorango/undertow-poc | 21c01da058a54a9be1a360302eac33e5f3ea0499 | 0731f8b4e4a3597fe67c34a4bd6acdc08dab2632 | refs/heads/master | 2020-03-12T18:31:21.850280 | 2018-05-02T22:32:47 | 2018-05-02T22:32:47 | 130,762,169 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 241 | java | package com.model.enums;
public enum TransactionStatus {
PENDING,
APPROVED,
REFUSED,
CANCELLED,
FRAUD;
public static TransactionStatus of(String name) {
return name != null ? valueOf(name) : null;
}
}
| [
"edvmorango@gmail.com"
] | edvmorango@gmail.com |
97272fc65f69d36161e0b1203c53d9e5cfa81baf | 8d5df0abd61ef29aef90fb711af53a97a8964067 | /app/src/main/java/com/coolweather/android/gson/AQI.java | 337eb4a6da32bf7fd3ee7024c6f645b5be826897 | [
"Apache-2.0"
] | permissive | BlackMambaKB20/coolweather | 280a13050ab14e38cc3796a30c80ce772dad7a8e | 30e93d5e27802f355589b0c23552ab933f7d4411 | refs/heads/master | 2021-01-23T05:50:31.725743 | 2017-10-18T08:29:51 | 2017-10-18T08:29:51 | 102,476,844 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 370 | java | package com.coolweather.android.gson;
/**
* AQI:Air Quality Index 空气质量指数
*
* "aqi":{
* "city":{
* "aqi":"44",
* "pm25":"13"
* }
* }
*
* */
public class AQI {
public AQICity city;
public class AQICity {
public String aqi;//Air Quality Index 空气质量指数
public String pm25;//PM2.5
}
}
| [
"syd_sun@qq.com"
] | syd_sun@qq.com |
56b9af5a75a793abae645da7cc784a36a0598b71 | 4d04044089da10702bbeb53397aa82a10c73a3e6 | /src/main/java/model/Service.java | 6a91ba6fe34070d70bf20d7be05cb8fada5844fa | [] | no_license | prahladawasthi/CFHashMapService | d1a6c794c65fd84202b5d2e0cc25bf59524daf6e | 0567b6d5800fcf4f592d40d7eb606deb22cfb5d4 | refs/heads/master | 2021-01-01T16:24:00.526503 | 2017-07-20T11:40:31 | 2017-07-20T11:40:31 | 97,825,867 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,139 | java | package model;
import java.util.HashSet;
import java.util.Set;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
@Document(collection = "services")
public class Service {
@Id
private String id;
@Field
private String name;
@Field
private String description;
@Field
private boolean bindable;
@Field
private Set<Plan> plans = new HashSet<>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isBindable() {
return bindable;
}
public void setBindable(boolean bindable) {
this.bindable = bindable;
}
public Set<Plan> getPlans() {
return plans;
}
public void setPlans(Set<Plan> plans) {
this.plans = plans;
}
public void addPlan(Plan plan) {
this.plans.add(plan);
}
}
| [
"noreply@github.com"
] | prahladawasthi.noreply@github.com |
f09b87cda4e7666512920c4e8db24eb295433756 | dd4e021c7d3c963907ebaca74f1c86c7da05d9b0 | /src/hps/nyu/fa14/solve/AbstractGenerator.java | 84a463ebba86039b272340f5af0b551be4e25239 | [] | no_license | genghis88/Darwin | a35e013acd709d053c070a72288c53a9dc9f9658 | 2e92b9896217840bd7ba8ecd1913e9e63eaa7df2 | refs/heads/master | 2021-01-18T02:19:51.966598 | 2014-11-06T04:37:33 | 2014-11-06T04:37:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,087 | java | package hps.nyu.fa14.solve;
import hps.nyu.fa14.IGenerator;
import hps.nyu.fa14.ISolutionMonitor;
import hps.nyu.fa14.Matrix;
import hps.nyu.fa14.TableSum;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractGenerator implements IGenerator {
@Override
public abstract List<Matrix> generate(TableSum tableSum);
protected List<ISolutionMonitor> monitors = new ArrayList<ISolutionMonitor>();
@Override
public void addSolutionMonitor(ISolutionMonitor monitor) {
monitors.add(monitor);
}
protected void notifyNewSolution(Matrix solution) {
for (ISolutionMonitor m : monitors) {
m.updateSolution(solution);
}
}
private Matrix bestSolution;
private int bestValue;
protected boolean updateIfBest(Matrix m) {
int corr = m.correlation();
if (corr > bestValue) {
bestSolution = m;
bestValue = corr;
notifyNewSolution(m);
return true;
}
return false;
}
}
| [
"ck1456@nyu.edu"
] | ck1456@nyu.edu |
d091c7437d2d69d7a2c1a719765c2370897daa34 | 59f0f02b103c41fcf853bf8ad7a90979c61b1e09 | /public/app/src/main/java/com/garagem/nupark/service/GaragemService.java | 0e7330ff6dded9441764f380931a5fc166665c05 | [] | no_license | phsantiago/garagem_app | 8d78276d49beb587b1f43ef51832c1a129a47562 | 3f27646c08f522733d71aabc534d577b0017625c | refs/heads/master | 2021-03-24T00:13:19.641617 | 2016-09-25T19:32:18 | 2016-09-25T19:32:18 | 63,114,453 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 978 | java | package com.garagem.nupark.service;
import android.content.Context;
import com.garagem.nupark.dto.GaragemDto;
import com.garagem.nupark.dto.PosicaoDto;
import com.garagem.nupark.dto.UsuarioDto;
import com.google.gson.JsonObject;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
import system.Config;
/**
* Created by Gabriel on 18/07/2016.
*/
public class GaragemService {
public void consultaGaragem(GaragemDto posicaoDto, Context applicationContext, FutureCallback futureCallback){
// JsonObject json = new JsonObject();
// json.addProperty("email",usuarioDto.getEmail());
// json.addProperty("nome",usuarioDto.getNome());
Ion.with(applicationContext)
.load(Config.HTTP_HOST +"/garagem")
.setHeader("Content-Type","application/json")
// .setJsonObjectBody(json)
.asJsonArray()
.setCallback(futureCallback);
}
}
| [
"pedroh_s_@hotmail.com"
] | pedroh_s_@hotmail.com |
36ebe2b19c5fc1a72823a32e3666d23c18b429fc | 7014ac170e524515e18cebc311bd8b301e7c2c33 | /app/src/main/java/com/example/gridview/img.java | 434009c413f8ea4f1cad77135cd379a9d9d498ac | [] | no_license | pulkitgupt14/gridsample | f9f7df1f0b34b420f1cc01a64e50d5e43bd81b72 | 69ea5bf850c3014784a1c748e6f3e956bed54743 | refs/heads/master | 2023-06-20T15:34:11.056707 | 2021-07-22T06:53:33 | 2021-07-22T06:53:33 | 385,542,736 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,257 | java | package com.example.gridview;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.Image;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.ImageView;
import java.io.File;
public class img extends AppCompatActivity implements View.OnClickListener{
Bitmap bmp;
Image img;
static int width = 600;
static int height= 300;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_imageview);
Intent intent =getIntent();
String path = getIntent().getStringExtra("image");
Bitmap bitmap=null;
try
{
bitmap = MediaStore.Images.Media.getBitmap(img.this.getContentResolver()
, Uri.fromFile(new File(path)));
}
catch(Exception e)
{
System.out.println(e.getStackTrace());
}
ImageView imageView=(ImageView)findViewById(R.id.hello);
ViewTreeObserver vto = imageView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
com.example.gridview.img.width = imageView.getMeasuredWidth();
com.example.gridview.img.height = imageView.getMeasuredHeight();
}
});
System.out.println(com.example.gridview.img.width);
bitmap= ThumbnailUtils.extractThumbnail(bitmap,com.example.gridview.img.width,com.example.gridview.img.height);
imageView.setImageBitmap(bitmap);
Button mButton = findViewById(R.id.back);
mButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.back:
Intent intent = new Intent(this, gridact.class);
startActivity(intent);
break;
}
}
} | [
"pulkit14gupta11@gmail.com"
] | pulkit14gupta11@gmail.com |
12566e697665805415e1f79b2f298e46225ff42d | fbf715c274b41185a9d1d98cd4bb978ebd642c5b | /plugin-sonatype/src/test/java/com/tracelink/prodsec/plugin/sonatype/service/SonatypeClientServiceTest.java | 7611aa763050842df560a14aebf1248df8b22626 | [
"MIT"
] | permissive | joshnewton31080/synapse | 34a107cf54220c8e4c3f02499770d3a5b5935ff6 | b63b74fcb2666d63ece17998781cd0ca7034242c | refs/heads/main | 2023-06-16T15:15:32.790094 | 2021-06-30T03:04:04 | 2021-06-30T03:04:04 | 381,554,846 | 0 | 0 | MIT | 2021-07-14T14:11:16 | 2021-06-30T02:41:22 | Java | UTF-8 | Java | false | false | 11,753 | java | package com.tracelink.prodsec.plugin.sonatype.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.tracelink.prodsec.plugin.sonatype.mock.LoggerRule;
import com.tracelink.prodsec.plugin.sonatype.model.SonatypeApp;
import com.tracelink.prodsec.plugin.sonatype.model.SonatypeClient;
import com.tracelink.prodsec.plugin.sonatype.repository.SonatypeClientRepository;
import com.tracelink.prodsec.plugin.sonatype.util.client.Application;
import com.tracelink.prodsec.plugin.sonatype.util.client.ApplicationTag;
import com.tracelink.prodsec.plugin.sonatype.util.client.ApplicationViolation;
import com.tracelink.prodsec.plugin.sonatype.util.client.ApplicationViolations;
import com.tracelink.prodsec.plugin.sonatype.util.client.Applications;
import com.tracelink.prodsec.plugin.sonatype.util.client.Component;
import com.tracelink.prodsec.plugin.sonatype.util.client.ComponentIdentifier;
import com.tracelink.prodsec.plugin.sonatype.util.client.ConstraintViolation;
import com.tracelink.prodsec.plugin.sonatype.util.client.Coordinates;
import com.tracelink.prodsec.plugin.sonatype.util.client.Policies;
import com.tracelink.prodsec.plugin.sonatype.util.client.Policy;
import com.tracelink.prodsec.plugin.sonatype.util.client.PolicyViolation;
import com.tracelink.prodsec.plugin.sonatype.util.client.Reason;
import java.util.Collections;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.BDDMockito;
import org.mockito.Mockito;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
public class SonatypeClientServiceTest {
@MockBean
private SonatypeAppService appService;
@MockBean
private SonatypeMetricsService metricsService;
@MockBean
private SonatypeClientRepository clientRepository;
private SonatypeClientService clientService;
private SonatypeClient client;
@Rule
public final LoggerRule loggerRule = LoggerRule.forClass(SonatypeClientService.class);
@Rule
public final WireMockRule wireMockRule = new WireMockRule(
WireMockConfiguration.wireMockConfig().dynamicPort());
@Before
public void setup() {
clientService = new SonatypeClientService(appService, metricsService, clientRepository);
client = new SonatypeClient();
client.setApiUrl(wireMockRule.baseUrl());
client.setUser("foo");
client.setAuth("barbaz");
}
@Test
public void testTestConnectionFailClient() {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.emptyList());
Assert.assertFalse(clientService.testConnection());
Assert.assertEquals("No Sonatype client configured.", loggerRule.getMessages().get(0));
}
@Test
public void testTestConnectionFailSonatype() {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.singletonList(client));
WireMock.stubFor(WireMock.get("/api/v2/applications")
.willReturn(WireMock.aResponse().withBody("invalid")));
Assert.assertFalse(clientService.testConnection());
}
@Test
public void testTestConnection() throws Exception {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.singletonList(client));
JSONObject json = new JSONObject().put("applications", new JSONArray());
WireMock.stubFor(WireMock.get("/api/v2/applications")
.withBasicAuth(client.getUser(), client.getAuth())
.willReturn(WireMock.okJson(json.toString())));
Assert.assertTrue(clientService.testConnection());
}
@Test
public void testFetchDataFailClient() {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.emptyList());
clientService.fetchData();
Assert.assertEquals("No Sonatype client configured.", loggerRule.getMessages().get(0));
}
@Test
public void testFetchDataFailSonatypeApplications() {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.singletonList(client));
WireMock.stubFor(WireMock.get("/api/v2/applications")
.willReturn(WireMock.aResponse().withBody("invalid")));
clientService.fetchData();
BDDMockito.verify(metricsService, Mockito.times(0))
.storeMetrics(BDDMockito.any(SonatypeApp.class),
BDDMockito.anyMap());
}
@Test
public void testFetchDataFailSonatypePolicies() throws Exception {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.singletonList(client));
ApplicationTag appTag = new ApplicationTag();
appTag.setId("jkl");
appTag.setApplicationId("123");
appTag.setTagId("Tag1");
Application app = new Application();
app.setId("123");
app.setPublicId("App1");
app.setName("App1");
app.setOrganizationId("456");
app.setContactUserName(null);
app.setApplicationTags(Collections.singletonList(appTag));
Applications apps = new Applications();
apps.setApplications(Collections.singletonList(app));
ObjectMapper om = new ObjectMapper();
WireMock.stubFor(WireMock.get("/api/v2/applications")
.withBasicAuth(client.getUser(), client.getAuth())
.willReturn(WireMock.okJson(om.writeValueAsString(apps))));
WireMock.stubFor(WireMock.get("/api/v2/policies")
.willReturn(WireMock.aResponse().withBody("invalid")));
clientService.fetchData();
BDDMockito.verify(metricsService, Mockito.times(0))
.storeMetrics(BDDMockito.any(SonatypeApp.class),
BDDMockito.anyMap());
}
@Test
public void testFetchDataFailSonatypeApplicationViolations() throws Exception {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.singletonList(client));
ApplicationTag appTag = new ApplicationTag();
appTag.setId("jkl");
appTag.setApplicationId("123");
appTag.setTagId("Tag1");
Application app = new Application();
app.setId("123");
app.setPublicId("App1");
app.setName("App1");
app.setOrganizationId("456");
app.setContactUserName(null);
app.setApplicationTags(Collections.singletonList(appTag));
Applications apps = new Applications();
apps.setApplications(Collections.singletonList(app));
Policy policy = new Policy();
policy.setId("789");
policy.setName("Policy1");
policy.setOwnerId("ROOT");
policy.setOwnerType("ORGANIZATION");
policy.setThreatLevel(1);
policy.setPolicyType("other");
Policies policies = new Policies();
policies.setPolicies(Collections.singletonList(policy));
ObjectMapper om = new ObjectMapper();
WireMock.stubFor(WireMock.get("/api/v2/applications")
.withBasicAuth(client.getUser(), client.getAuth())
.willReturn(WireMock.okJson(om.writeValueAsString(apps))));
WireMock.stubFor(
WireMock.get("/api/v2/policies").withBasicAuth(client.getUser(), client.getAuth())
.willReturn(WireMock.okJson(om.writeValueAsString(policies))));
WireMock.stubFor(
WireMock.get("/api/v2/policyViolations?p=789")
.willReturn(WireMock.aResponse().withBody("invalid")));
clientService.fetchData();
BDDMockito.verify(metricsService, Mockito.times(0))
.storeMetrics(BDDMockito.any(SonatypeApp.class),
BDDMockito.anyMap());
}
@Test
public void testFetchData() throws Exception {
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.singletonList(client));
ApplicationTag appTag = new ApplicationTag();
appTag.setId("jkl");
appTag.setApplicationId("123");
appTag.setTagId("Tag1");
Application app = new Application();
app.setId("123");
app.setPublicId("App1");
app.setName("App1");
app.setOrganizationId("456");
app.setContactUserName(null);
app.setApplicationTags(Collections.singletonList(appTag));
Applications apps = new Applications();
apps.setApplications(Collections.singletonList(app));
Policy policy = new Policy();
policy.setId("789");
policy.setName("Policy1");
policy.setOwnerId("ROOT");
policy.setOwnerType("ORGANIZATION");
policy.setThreatLevel(1);
policy.setPolicyType("other");
Policies policies = new Policies();
policies.setPolicies(Collections.singletonList(policy));
Reason reason = new Reason();
reason.setReason("Found security vulnerability.");
ConstraintViolation cv = new ConstraintViolation();
cv.setConstraintId("def");
cv.setConstraintName("High risk");
cv.setReasons(Collections.singletonList(reason));
Coordinates coordinates = new Coordinates();
coordinates.setArtifactId("artifact");
coordinates.setClassifier("");
coordinates.setExtension("jar");
coordinates.setGroupId("com.example");
coordinates.setVersion("1.0.0");
coordinates.setName("coordinates");
coordinates.setQualifier("qualifier");
ComponentIdentifier ci = new ComponentIdentifier();
ci.setFormat("maven");
ci.setCoordinates(coordinates);
Component component = new Component();
component.setPackageUrl("pkg");
component.setHash("ghi");
component.setComponentIdentifier(ci);
component.setProprietary(false);
PolicyViolation policyViolation = new PolicyViolation();
policyViolation.setPolicyId("789");
policyViolation.setPolicyName("Security-High");
policyViolation.setPolicyViolationId("abc");
policyViolation.setThreatLevel(9);
policyViolation.setConstraintViolations(Collections.singletonList(cv));
policyViolation.setStageId("build");
policyViolation.setReportUrl("report/url");
policyViolation.setComponent(component);
ApplicationViolation appVio = new ApplicationViolation();
appVio.setApplication(app);
appVio.setPolicyViolations(Collections.singletonList(policyViolation));
ApplicationViolations appVios = new ApplicationViolations();
appVios.setApplicationViolations(Collections.singletonList(appVio));
ObjectMapper om = new ObjectMapper();
WireMock.stubFor(WireMock.get("/api/v2/applications")
.withBasicAuth(client.getUser(), client.getAuth())
.willReturn(WireMock.okJson(om.writeValueAsString(apps))));
WireMock.stubFor(
WireMock.get("/api/v2/policies").withBasicAuth(client.getUser(), client.getAuth())
.willReturn(WireMock.okJson(om.writeValueAsString(policies))));
WireMock.stubFor(
WireMock.get("/api/v2/policyViolations?p=789")
.withBasicAuth(client.getUser(), client.getAuth())
.willReturn(WireMock.okJson(om.writeValueAsString(appVios))));
SonatypeApp sonatypeApp = new SonatypeApp();
sonatypeApp.setId("123");
sonatypeApp.setName("App1");
BDDMockito.when(appService.getAppForId("123", "App1")).thenReturn(sonatypeApp);
clientService.fetchData();
BDDMockito.verify(metricsService, Mockito.times(1))
.storeMetrics(BDDMockito.any(SonatypeApp.class),
BDDMockito.anyMap());
}
@Test
public void testSetClientNull() {
Assert.assertFalse(clientService.setClient(null, "foo", "bar"));
}
@Test
public void testSetClientInvalidUrl() {
Assert.assertFalse(clientService.setClient("foo", "bar", "baz"));
}
@Test
public void testSetClient() {
// Case where no client is set
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.emptyList());
Assert.assertTrue(clientService.setClient("http://example.com", "user", "auth"));
BDDMockito.verify(clientRepository, Mockito.times(1))
.saveAndFlush(BDDMockito.any(SonatypeClient.class));
// Case where no client is set
BDDMockito.when(clientRepository.findAll()).thenReturn(Collections.singletonList(client));
Assert.assertTrue(clientService.setClient("http://example.com", "user", "auth"));
BDDMockito.verify(clientRepository, Mockito.times(1)).saveAndFlush(client);
Assert.assertEquals("http://example.com", client.getApiUrl());
Assert.assertEquals("user", client.getUser());
Assert.assertEquals("auth", client.getAuth());
}
}
| [
"mcool@tracelink.com"
] | mcool@tracelink.com |
49d42b1f19692c607924fa6f880afea4617c4cc2 | 64e81457aa21ef359085d1ba3b4b831fb56ae8ad | /src/main/java/app/jitu/myapplication/DataBaseHelper.java | b9d3a80ea85f4fb2bcda3716e88dcf17e3412a5a | [] | no_license | kumar23jayant/Quick-In | 1e521469a308219f2bc67fcde22c0796f3c6ecd8 | 00dffd9691918176014e344b9949eb2ded1b51e0 | refs/heads/master | 2021-01-23T02:40:32.057572 | 2017-03-25T06:48:00 | 2017-03-25T06:48:00 | 86,017,564 | 1 | 4 | null | 2017-03-25T06:48:00 | 2017-03-24T02:14:23 | Java | UTF-8 | Java | false | false | 1,772 | java | package app.jitu.myapplication;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by root on 3/24/17.
*/
public class DataBaseHelper extends SQLiteOpenHelper {
// Table Name
public static final String TABLE_NAME = "accounts";
public static final String TABLE_NAME1 = "session";
// Table columns
public static final String _ID = "_id";
public static final String USER = "username";
public static final String PASS = "password";
public static final String _Unique="_uid";
public static final String _ID1 = "_id1";
public static final String KEY = "key";
public static final String PC = "pcname";
static final String DB_NAME = "Mydatabase.DB";
static final int DB_VERSION = 4;
// Creating table query
private static final String CREATE_TABLE = "create table " + TABLE_NAME + "(" +_Unique+" INTEGER PRIMARY KEY AUTOINCREMENT, "+ _ID + " TEXT NOT NULL "
+ " , " + USER + " TEXT NOT NULL, " + PASS + " TEXT NOT NULL);";
private static final String CREATE_TABLE1= "create table " + TABLE_NAME1 + "(" +_ID1+" INTEGER PRIMARY KEY AUTOINCREMENT, "+ KEY + " TEXT NOT NULL "
+ " , " + PC + " TEXT NOT NULL );";
public DataBaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE);
db.execSQL(CREATE_TABLE1);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME1);
onCreate(db);
}
}
| [
"noreply@github.com"
] | kumar23jayant.noreply@github.com |
25d9d945970e931998d8216581ba7a4faf82c84e | 3e350bdbd07a14d646d4e0fdbef3fa1079e1908a | /src/com/emp/controller/LoginHandler.java | 76a592b623c0d658a72af2807bb14ff6f1490335 | [] | no_license | AlvinChiou/XA803G2_final | d5b29db829e4729441d3598ca8390c1bc511e537 | 62b156c332ff0c89df81ad3387d1eaf48f53c8e0 | refs/heads/master | 2020-04-01T21:11:08.352228 | 2014-06-13T08:28:59 | 2014-06-13T08:28:59 | null | 0 | 0 | null | null | null | null | BIG5 | Java | false | false | 3,397 | java | package com.emp.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.emp.model.EmployeeService;
import com.emp.model.EmployeeVO;
import com.pow.model.PowDAO;
import com.pow.model.PowService;
import com.pow.model.PowVO;
public class LoginHandler extends HttpServlet {
EmployeeVO employeeVO = null;
protected boolean allowuser(Integer empNo, String empPassword){
EmployeeService employeeSvc = new EmployeeService();
employeeVO = employeeSvc.getOneEmp(empNo);
if(employeeVO==null){
return false;
}else if(!empPassword.equals(employeeVO.getEmpPassword())){
return false;
}else{
return true;
}
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doPost(req,res);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
res.setContentType("text/html; charset=Big5");
PrintWriter out = res.getWriter();
// 【取得使用者 帳號(empNo) 密碼(empPassword)】
Integer empNo = new Integer(req.getParameter("empNo"));
String empPassword = req.getParameter("empPassword");
// 【檢查該帳號 , 密碼是否有效】
if(!allowuser(empNo, empPassword)){ //帳號 , 密碼無效時
if(employeeVO==null){
out.println("<HTML><HEAD><TITLE>Access Denied</TITLE></HEAD>");
out.println("<BODY>無效的使用者帳戶!<BR>");
out.println("請按此重新登入 <A HREF="+req.getContextPath()+"/empLogin.jsp>重新登入</A>");
out.println("</BODY></HTML>");
}else{
out.println("<HTML><HEAD><TITLE>Access Denied</TITLE></HEAD>");
out.println("<BODY>帳號密碼錯誤 請重新輸入!<BR>");
out.println("請按此重新登入 <A HREF="+req.getContextPath()+"/empLogin.jsp>重新登入</A>");
out.println("</BODY></HTML>");
}
}else{ //帳號 密碼有效時, 才做以下工作
HttpSession session = req.getSession();
session.setAttribute("empNo", empNo); //*工作1: 才在session內做已經登入過的標識
session.setAttribute("employeeVO", employeeVO); //可以從裡面取出memName,顯示在首頁,XXX你好
PowService powSvc = new PowService();
List<PowVO> list = powSvc.getOnePow(empNo); //將權限存入SESSION
session.setAttribute("list", list); //將取到的權限存入session
try{ //*工作2: 看看有無來源網頁 (-如有:則重導之)
String location = (String)session.getAttribute("location");
if(location != null){
session.removeAttribute("location");
res.sendRedirect(location);
return;
}
}catch (Exception ignored){ }
res.sendRedirect(req.getContextPath()+"/index.jsp"); //*工作3: (如無來源網頁, 則重導至select_page.jsp網頁)
}
}
}
| [
"alvinhsian@gmail.com"
] | alvinhsian@gmail.com |
a689d2016be48fc56527704f2f54f181ba1b2a5a | fb7b030d462ab0a1a449dad08aeca61bf5bfba63 | /app/src/main/java/com/jxxx/gaotang/view/adapter/HomeActivityAdapter.java | 4d916e87cd5501c9ac0353f8b86c8d83dd197d50 | [] | no_license | ltg263/GaoTang | a15c5b51d8ce928795448a72793ce221ef8b5e3a | b687c6d5760f004f452a19923c532c6d04e33fc5 | refs/heads/master | 2022-07-04T21:36:44.512969 | 2020-05-25T03:03:57 | 2020-05-25T03:03:57 | 266,670,590 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 587 | java | package com.jxxx.gaotang.view.adapter;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jxxx.gaotang.R;
import java.util.List;
public class HomeActivityAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public HomeActivityAdapter(@Nullable List<String> data) {
super(R.layout.item_home_activity,data);
}
@Override
protected void convert(@NonNull BaseViewHolder helper, String item) {
}
}
| [
"qzj842179561@gmail.com"
] | qzj842179561@gmail.com |
3682e7358fdceb42ddfd4d85ca964d464d2d8cb6 | da35681eaf896c769ad3b49fa539654d8d86ee9f | /src/main/java/one/digitalinnovation/personapi/dto/request/PersonDTO.java | 602a92adbc7449204e5ddd38b8fd6b682d36e26e | [] | no_license | mlumoura/gerencia-pessoas-api-rest | 5d199edc9f2846c614b80cf2aed891eba39b5870 | f4653a0201003a4d356f903cbc9ebc65bc719cee | refs/heads/main | 2023-07-19T14:32:02.752409 | 2021-09-23T07:57:13 | 2021-09-23T07:57:13 | 408,050,800 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 869 | java | package one.digitalinnovation.personapi.dto.request;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.br.CPF;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PersonDTO {
private Long id;
@NotEmpty
@Size(min = 2, max = 100)
private String firstName;
@NotEmpty
@Size(min = 2, max = 100)
private String lastName;
@NotEmpty
@CPF
private String cpf;
@Size(min = 10, max = 50)
private String email;
@NotNull
private String birthDate;
@Valid
@NotEmpty
private List<PhoneDTO> phones;
}
| [
"86756987+mlumoura@users.noreply.github.com"
] | 86756987+mlumoura@users.noreply.github.com |
b5b45b91ba11b3e0d3c9dd3dc97bf797a647b9c1 | 48ffd4b0667b16d75c3786a5d62cf9a6560cec38 | /MITWebSite/src/main/java/com/mit/daoImpl/ContratDAOImpl.java | 36bf9dc7507f23dbf029b63a6c1e07a281e740d1 | [] | no_license | tayssirw/MITWebSite | 88552a2b7f935e12e0e7369bf1cc4bc79b28a91e | 33136a84711a9e7923560cbcc08b5b3f429d1dc5 | refs/heads/master | 2021-01-01T05:45:42.803453 | 2016-05-04T09:56:43 | 2016-05-04T10:01:03 | 56,730,009 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 330 | java | package com.mit.daoImpl;
import com.mit.dao.ContratDAO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
//@Repository("contratDao")
@Service("contratDao")
@Transactional
public class ContratDAOImpl extends GenericDAOImpl implements ContratDAO {
}
| [
"werfelli@werfelli-PC"
] | werfelli@werfelli-PC |
6adf818e615ccbd01668e270f05f0b8bd10799fc | 2ec7327bf5ae60b2fcbbba452cac737763a15b87 | /core/src/test/java/org/pentaho/di/core/util/StringEvaluatorTest.java | e5d1bd58e9a4fac4e17ba0820f6edfc9cfe322d0 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | jamespatriot/Kettle8 | fb15b55c880ffde93428f532121464656e7989df | baf83fdf58f35dcbcb886de023b3d4f0ac22b691 | refs/heads/master | 2020-04-01T12:55:52.177213 | 2018-08-08T10:13:12 | 2018-08-08T10:13:12 | 153,230,029 | 0 | 1 | Apache-2.0 | 2018-10-16T05:55:20 | 2018-10-16T05:55:19 | null | UTF-8 | Java | false | false | 11,271 | java | /*! ******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
* 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.pentaho.di.core.util;
import static org.junit.Assert.*;
import java.util.*;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Test class for StringEvaluator functionality.
*
* @author Alexander Buloichik
*/
public class StringEvaluatorTest {
private StringEvaluator evaluator;
private static Locale defaultLocale;
@BeforeClass
public static void setUpClass() {
defaultLocale = Locale.getDefault();
}
@Before
public void setUp() {
evaluator = new StringEvaluator();
Locale.setDefault(Locale.US);
}
@AfterClass
public static void tearDown() {
Locale.setDefault(defaultLocale);
}
/////////////////////////////////////
// common
////////////////////////////////////
@Test
public void testEmpty() {
evaluator.evaluateString("");
assertTrue(evaluator.getStringEvaluationResults().isEmpty());
evaluator.evaluateString(" ");
assertTrue(evaluator.getStringEvaluationResults().isEmpty());
}
@Test
public void testGetValues_WithoutDublicate() {
List<String> strings = Arrays.asList("name1", "name2");
for (String string : strings) {
evaluator.evaluateString(string);
}
assertEquals(strings.size(), evaluator.getValues().size());
List<String> actualStrings = new ArrayList<String>(evaluator.getValues());
Collections.sort(strings);
Collections.sort(actualStrings);
Iterator<String> exIterator = strings.iterator();
Iterator<String> iterator = actualStrings.iterator();
while (iterator.hasNext()) {
assertEquals(exIterator.next(), iterator.next());
}
}
@Test
public void testGetValues_Duplicate() {
String dublicatedString = "name1";
List<String> strings = Arrays.asList(dublicatedString);
for (String string : strings) {
evaluator.evaluateString(string);
}
evaluator.evaluateString(dublicatedString);
assertEquals(strings.size(), evaluator.getValues().size());
Iterator<String> exIterator = strings.iterator();
Iterator<String> iterator = evaluator.getValues().iterator();
while (iterator.hasNext()) {
assertEquals(exIterator.next(), iterator.next());
}
}
@Test
public void testGetCount() {
List<String> strings = Arrays.asList("02/29/2000", "03/29/2000");
for (String string : strings) {
evaluator.evaluateString(string);
}
assertEquals(strings.size(), evaluator.getCount());
}
@Test
public void testGetAdvicedResult_NullInput() {
String expectedNull = "";
List<String> strings = Arrays.asList(expectedNull);
for (String string : strings) {
evaluator.evaluateString(string);
}
StringEvaluationResult result = evaluator.getAdvicedResult();
assertEquals(1, result.getNrNull());
}
@Test
public void testGetAdvicedResult_MinMaxInput() {
String expectedMin = "500";
String expectedMax = "1000";
List<String> strings = Arrays.asList(expectedMax, expectedMin);
for (String string : strings) {
evaluator.evaluateString(string);
}
StringEvaluationResult result = evaluator.getAdvicedResult();
assertEquals(Long.parseLong(expectedMax), result.getMax());
assertEquals(Long.parseLong(expectedMin), result.getMin());
assertEquals(expectedMax.length(), evaluator.getMaxLength());
}
/////////////////////////////////////
// mixed types
////////////////////////////////////
@Test
public void testIntegerWithNumber() {
List<String> strings = Arrays.asList("1", "1.1");
String mask = "#.#";
for (String string : strings) {
evaluator.evaluateString(string);
}
assertFalse(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isNumber());
assertTrue(mask.equals(evaluator.getAdvicedResult().getConversionMeta().getConversionMask()));
}
/////////////////////////////////////
// number types
////////////////////////////////////
@Test
public void testNumberWithPoint() {
testNumber("#.#", "1.1");
}
@Test
public void testNumberWithGroupAndPoint() {
testNumber("#,###,###.#", "1,111,111.1");
}
@Test
public void testNumbers() {
testNumber("#,###,###.#", "1,111,111.1", "1,111");
}
@Test
public void testStringAsNumber() {
evaluator.evaluateString("1");
evaluator.evaluateString("1.111111111");
evaluator.evaluateString("1,111");
evaluator.evaluateString("1,111.11111111");
evaluator.evaluateString("1,111,111.1111");
evaluator.evaluateString("1,111.111.1111");
evaluator.evaluateString("1,111,111.111.111");
assertTrue(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isString());
}
private void testNumber(String mask, String... strings) {
for (String string : strings) {
evaluator.evaluateString(string);
}
assertFalse(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isNumber());
assertTrue(mask.equals(evaluator.getAdvicedResult().getConversionMeta().getConversionMask()));
}
/////////////////////////////////////
// integer types
////////////////////////////////////
@Test
public void testInteger() {
testInteger("#", "1");
}
@Test
public void testIntegerWithGroup() {
testInteger("#", "1111");
}
private void testInteger(String mask, String... strings) {
for (String string : strings) {
evaluator.evaluateString(string);
}
assertFalse(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isInteger());
assertTrue(mask.equals(evaluator.getAdvicedResult().getConversionMeta().getConversionMask()));
}
/////////////////////////////////////
// currency types
////////////////////////////////////
@Test
public void testCurrency() {
testCurrencyBasic("+123", "-123", "(123)");
}
private void testCurrencyBasic(String... strings) {
for (String string : strings) {
evaluator.evaluateString(string);
}
assertTrue(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isString());
}
/////////////////////////////////////
// boolean types
////////////////////////////////////
@Test
public void testBooleanY() {
testBoolean("Y");
}
@Test
public void testBooleanN() {
testBoolean("N");
}
@Test
public void testBooleanTrue() {
testBoolean("True");
}
@Test
public void testBooleanFalse() {
testBoolean("False");
}
private void testBoolean(String... strings) {
for (String string : strings) {
evaluator.evaluateString(string);
}
assertFalse(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isBoolean());
}
/////////////////////////////////////
// Date types, use default USA format
////////////////////////////////////
@Test
public void testDate() {
testDefaultDateFormat("MM/dd/yyyy", "10/10/2000");
}
@Test
public void testDateArray() {
testDefaultDateFormat("MM/dd/yyyy", "10/10/2000", "11/10/2000", "12/10/2000");
}
@Test
public void testTimeStamp() {
testDefaultDateFormat("MM/dd/yyyy HH:mm:ss", "10/10/2000 00:00:00");
}
@Test
public void testTimeStampSeconds() {
testDefaultDateFormat("MM/dd/yyyy HH:mm:ss", "10/10/2000 00:00:00");
}
private void testDefaultDateFormat(String maskEn, String... strings) {
for (String string : strings) {
evaluator.evaluateString(string);
}
assertFalse(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isDate());
String actualMask = evaluator.getAdvicedResult().getConversionMeta().getConversionMask();
assertTrue(maskEn.equals(actualMask));
}
@Test
public void testDate2YearDigits() {
testDefaultDateFormat("MM/dd/yy", "10/10/20", "11/10/20", "12/10/20");
}
@Test
public void testCustomDateFormat() {
String sampleFormat = "MM/dd/yyyy HH:mm:ss";
ArrayList<String> dateFormats = new ArrayList<String>();
dateFormats.add(sampleFormat);
StringEvaluator evaluator = new StringEvaluator(true, new ArrayList<String>(), dateFormats);
evaluator.evaluateString("02/29/2000 00:00:00");
assertFalse(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isDate());
assertTrue(sampleFormat.equals(evaluator.getAdvicedResult().getConversionMeta().getConversionMask()));
}
@Test
public void testAdviceedOneDateFormat() {
String sampleLongFormat = "MM/dd/yyyy HH:mm:ss";
String sampleShortFormat = "MM/dd/yy HH:mm:ss";
ArrayList<String> dateFormats = new ArrayList<String>();
dateFormats.add(sampleLongFormat);
dateFormats.add(sampleShortFormat);
StringEvaluator evaluator = new StringEvaluator(true, new ArrayList<String>(), dateFormats);
evaluator.evaluateString("02/29/20 00:00:00");
assertFalse(evaluator.getStringEvaluationResults().isEmpty());
assertTrue(evaluator.getAdvicedResult().getConversionMeta().isDate());
assertFalse(sampleLongFormat.equals(evaluator.getAdvicedResult().getConversionMeta().getConversionMask()));
//should advice short format
assertTrue(sampleShortFormat.equals(evaluator.getAdvicedResult().getConversionMeta().getConversionMask()));
}
}
| [
"xiao5406710@foxmail.com"
] | xiao5406710@foxmail.com |
a1d956171661fecd45977d8bfe523d52f37289c8 | 4428611413d3e37793c92e5b35a549b991887448 | /bizislife/src/main/java/com/bizislife/core/hibernate/pojo/TopicVisibleOrg.java | 2c5e7dfc47bcfd8c81c0284f51a0d4c5b347912a | [] | no_license | stonegu/bizislife_v1 | c370c25bea5bb7f8dbf4e0ab8191603a032a7066 | 9d686ec90be9aa510d729f86f62a141ac07527c7 | refs/heads/master | 2021-01-20T12:06:33.588647 | 2015-11-24T04:31:56 | 2015-11-24T04:31:56 | 46,767,223 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,672 | java | package com.bizislife.core.hibernate.pojo;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
@Entity
@Table(name="topicvisibleorg")
public class TopicVisibleOrg implements PojoInterface, Serializable{
private static final long serialVersionUID = 2289707569801945505L;
@Id
@Column(name="id")
@GeneratedValue
private Long id;
@Column(name="topic_id")
private Long topic_id;
@Column(name="topicuuid")
private String topicuuid;
@Column(name="organization_id")
private Long organization_id;
public TopicVisibleOrg() {
super();
}
public TopicVisibleOrg(Long id, Long topic_id, String topicuuid, Long organization_id) {
super();
this.id = id;
this.topic_id = topic_id;
this.topicuuid = topicuuid;
this.organization_id = organization_id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getTopic_id() {
return topic_id;
}
public void setTopic_id(Long topic_id) {
this.topic_id = topic_id;
}
public String getTopicuuid() {
return topicuuid;
}
public void setTopicuuid(String topicuuid) {
this.topicuuid = topicuuid;
}
public Long getOrganization_id() {
return organization_id;
}
public void setOrganization_id(Long organization_id) {
this.organization_id = organization_id;
}
@Override
public String toString(){
return new ToStringBuilder(this).append("id", id).append("topic", topic_id).append("org", organization_id).toString();
}
}
| [
"sgu@hubba.com"
] | sgu@hubba.com |
d6afe7c39d12950cf6d90ae311557cf8ba32ae8f | 0da2f3e6dced12facd264be5ce40144f3e1fe202 | /android/ISTInventoryManagement/app/src/main/java/torvalds/istinventorymanagement/model/Checkin.java | cfdb34dda3bf40aca88adcdc7c61db252c197f8d | [] | no_license | ibrcic/torvalds-senior-dev | 4a5c3ace13d8bda5eee43679e1594102db413b32 | b611574b0fcf37049b2299b7a1beb5ed6d3ae96a | refs/heads/master | 2021-01-20T07:12:46.590296 | 2017-05-04T03:41:28 | 2017-05-04T03:41:28 | 80,349,480 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 708 | java | package torvalds.istinventorymanagement.model;
import java.util.ArrayList;
import java.util.List;
/**
* Created by ivan on 4/30/17.
*/
public class Checkin {
private long userId;
private List<ItemRental> idItemReturnList;
public Checkin(long userId) {
this.userId = userId;
this.idItemReturnList = new ArrayList<>();
}
public void addItemRental(ItemRental itemRental) {
idItemReturnList.add(itemRental);
}
public static class ItemRental {
private long itemId;
private long rentalId;
public ItemRental(long itemId, long rentalId) {
this.itemId = itemId;
this.rentalId = rentalId;
}
}
}
| [
"ivan@Ivans-MacBook-Pro.local"
] | ivan@Ivans-MacBook-Pro.local |
c45bdfd7a4ac8db4685771ad7bec4365abf55bad | 03ba5e5d2b0b9e27e1dd2ad87583b358fe66e29e | /wcOO/counters/LineCounter.java | c6c3008a3cf01148d182fb4367b3e97cf7e0252c | [] | no_license | Mah514/wcOO | 799a58493255a36f29ace26d48a8382546c16c6c | c52ffa2338db7e7d645430d590e6c246f1bab483 | refs/heads/main | 2023-04-22T15:53:38.055255 | 2021-05-06T01:55:36 | 2021-05-06T01:55:36 | 312,903,580 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 735 | java | package wcOO.counters;
import wcOO.fileManager.IFileManager;
import java.util.ArrayList;
//Counts the number of lines in file
class LineCounter extends Counter {
//Returns the size of the ArrayList of lines
@Override
public void count(ArrayList<String> line){
count = line.size();
if (opt.isEnabled() && opt.isRequired()) {
System.out.print("Verbose : ");
for(int i = 0; i < count; i++)
System.out.print("l");
}
System.out.println("\nLine Count : " + getCount()+"\n");
count = 0;
}
@Override
public void setFiles(ArrayList<IFileManager> file) {
}
@Override
public void resetCount() {
count = 0;
}
}
| [
"72531358+Mah514@users.noreply.github.com"
] | 72531358+Mah514@users.noreply.github.com |
2b55c5cc80ae0526a7e3699c595acbf7ca0bbd77 | 0db4c5c456b3280db33b956f5e0f4661afc2c946 | /src/test/java/edu/scau/BookstoreApplicationTests.java | 39af44d8059b352f88c8fe249a913985dd0102ee | [] | no_license | httpdocs/bookstore | 43c23d4fceb3609b1d9eaf6650beb56ba8ae6ea0 | dff838b2cc2b8c626cb6b961b4dfb3fc29eee00b | refs/heads/master | 2021-01-01T20:09:36.787463 | 2017-07-06T14:20:41 | 2017-07-06T14:20:41 | 98,781,150 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 508 | java | package edu.scau;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = BookstoreApplication.class)
@WebAppConfiguration
public class BookstoreApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"yszhong95@vip.qq.com"
] | yszhong95@vip.qq.com |
3acf10f17593ed2fe2d4e38a5b6d7efa830d1076 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_de62ce6bb001aa34f044e37987e71327513c3079/ResourceTree/2_de62ce6bb001aa34f044e37987e71327513c3079_ResourceTree_t.java | 342a455a7c439dd8154bec34d66020ce88a44f50 | [] | 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 | 41,810 | java | /**********************************************************************
* Copyright (c) 2002 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM - Initial API and implementation
**********************************************************************/
package org.eclipse.core.internal.resources;
import java.io.*;
import org.eclipse.core.internal.localstore.*;
import org.eclipse.core.internal.properties.PropertyManager;
import org.eclipse.core.internal.utils.Assert;
import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.*;
import org.eclipse.core.resources.team.IResourceTree;
import org.eclipse.core.runtime.*;
/**
* @since 2.0
*/
class ResourceTree implements IResourceTree {
MultiStatus status;
boolean isValid = true;
/**
* Constructor for this class.
*/
public ResourceTree(MultiStatus status) {
super();
this.status = status;
}
/**
* The specific operation for which this tree was created has completed and this tree
* should not be used anymore. Ensure that this is the case by making it invalid. This
* is checked by all API methods.
*/
void makeInvalid() {
this.isValid = false;
}
/**
* @see IResourceTree#addToLocalHistory(IFile)
*/
public void addToLocalHistory(IFile file) {
Assert.isLegal(isValid);
if (!file.exists())
return;
IPath path = file.getLocation();
if (path == null || !path.toFile().exists())
return;
long lastModified = internalComputeTimestamp(path.toOSString());
((Resource) file).getLocalManager().getHistoryStore().addState(file.getFullPath(), path, lastModified, false);
}
/**
* @see IResourceTree#movedFile(IFile, IFile)
*/
public void movedFile(IFile source, IFile destination) {
Assert.isLegal(isValid);
// Do nothing if the resource doesn't exist.
if (!source.exists())
return;
// If the destination already exists then we have a problem.
if (destination.exists()) {
String message = Policy.bind("resources.mustNotExist", destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, destination.getFullPath(), message);
// log the status but don't return until we try and move the rest of the resource information.
failed(status);
}
// Move the resource's persistent properties.
PropertyManager propertyManager = ((Resource) source).getPropertyManager();
try {
propertyManager.copy(source, destination, IResource.DEPTH_ZERO);
propertyManager.deleteProperties(source, IResource.DEPTH_ZERO);
} catch (CoreException e) {
String message = Policy.bind("resources.errorPropertiesMove", source.getFullPath().toString(), destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource information.
failed(status);
}
// Move the node in the workspace tree.
Workspace workspace = (Workspace) source.getWorkspace();
try {
workspace.move((Resource) source, destination.getFullPath(), IResource.DEPTH_ZERO, false);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMoving", source.getFullPath().toString(), destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource information.
failed(status);
}
// Generate the marker deltas.
try {
workspace.getMarkerManager().moved(source, destination, IResource.DEPTH_ZERO);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMarkersDelete", source.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
failed(status);
}
}
/**
* @see IResourceTree#movedFolderSubtree(IFolder, IFolder)
*/
public void movedFolderSubtree(IFolder source, IFolder destination) {
Assert.isLegal(isValid);
// Do nothing if the source resource doesn't exist.
if (!source.exists())
return;
// If the destination already exists then we have an error.
if (destination.exists()) {
String message = Policy.bind("resources.mustNotExist", destination.getFullPath().toString());
IStatus status= new ResourceStatus(IStatus.ERROR, destination.getFullPath(), message);
failed(status);
return;
}
// Move the folder properties.
int depth = IResource.DEPTH_INFINITE;
PropertyManager propertyManager = ((Resource) source).getPropertyManager();
try {
propertyManager.copy(source, destination, depth);
propertyManager.deleteProperties(source, depth);
} catch (CoreException e) {
String message = Policy.bind("resources.errorPropertiesMove", source.getFullPath().toString(), destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource info
failed(status);
}
// Create the destination node in the tree.
Workspace workspace = (Workspace) source.getWorkspace();
try {
workspace.move((Resource) source, destination.getFullPath(), depth, false);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMoving", source.getFullPath().toString(), destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource info
failed(status);
}
// Generate the marker deltas.
try {
workspace.getMarkerManager().moved(source, destination, depth);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMarkersDelete", source.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
failed(status);
}
}
/**
* @see IResourceTree#movedProject(IProject, IProject)
*/
public boolean movedProjectSubtree(IProject project, IProjectDescription destDescription) {
Assert.isLegal(isValid);
// Do nothing if the source resource doesn't exist.
if (!project.exists())
return true;
Project source = (Project) project;
Project destination = (Project) source.getWorkspace().getRoot().getProject(destDescription.getName());
IProjectDescription srcDescription = source.internalGetDescription();
Workspace workspace = (Workspace) source.getWorkspace();
int depth = IResource.DEPTH_INFINITE;
// If the name of the source and destination projects are not the same then
// rename the meta area and make changes in the tree.
if (isNameChange(source, destDescription)) {
if (destination.exists()) {
String message = Policy.bind("resources.mustNotExist", destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, destination.getFullPath(), message);
failed(status);
return false;
}
// Rename the project metadata area. Close the property store so bogus values
// aren't copied to the destination.
// FIXME: do we need to do this?
try {
source.getPropertyManager().closePropertyStore(source);
} catch (CoreException e) {
String message = Policy.bind("properties.couldNotClose", source.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource info
failed(status);
}
java.io.File oldMetaArea = workspace.getMetaArea().locationFor(source).toFile();
java.io.File newMetaArea = workspace.getMetaArea().locationFor(destination).toFile();
try{
source.getLocalManager().getStore().move(oldMetaArea, newMetaArea, false, new NullProgressMonitor());
} catch (CoreException e) {
String message = Policy.bind("resources.moveMeta", oldMetaArea.toString(), newMetaArea.toString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_METADATA, destination.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource info
failed(status);
}
// Move the workspace tree.
try {
workspace.move(source, destination.getFullPath(), depth, false);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMoving", source.getFullPath().toString(), destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource info
failed(status);
}
// Clear the natures and builders on the destination project.
ProjectInfo info = (ProjectInfo) destination.getResourceInfo(false, true);
info.clearNatures();
info.setBuilders(null);
// Generate marker deltas.
try {
workspace.getMarkerManager().moved(source, destination, depth);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMarkersMove", source.getFullPath().toString(), destination.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
// log the status but don't return until we try and move the rest of the resource info
failed(status);
}
}
// Set the new project description on the destination project.
try {
destination.internalSetDescription(destDescription, false);
destination.writeDescription(IResource.FORCE);
} catch (CoreException e) {
String message = Policy.bind("resources.projectDesc");
IStatus status = new ResourceStatus(IStatus.ERROR, destination.getFullPath(), message, e);
failed(status);
}
// If the locations are the not the same then make sure the new location is written to disk.
// (or the old one removed)
if (srcDescription.getLocation() == null) {
if (destDescription.getLocation() != null) {
try {
workspace.getMetaArea().writeLocation(destination);
} catch (CoreException e) {
// FIXME
}
}
} else {
if (!srcDescription.getLocation().equals(destDescription.getLocation())) {
try {
workspace.getMetaArea().writeLocation(destination);
} catch(CoreException e) {
// FIXME
}
}
}
// Do a refresh on the destination project to pick up any newly discovered resources
try {
destination.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e) {
String message = Policy.bind("resources.errorRefresh", destination.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.ERROR, destination.getFullPath(), message, e);
failed(status);
return false;
}
return true;
}
/**
* Returns the status object held onto by this resource tree.
*/
protected IStatus getStatus() {
return status;
}
/**
* @see IResourceTree#getTimestamp
*/
public long getTimestamp(IFile file) {
Assert.isLegal(isValid);
if (!file.exists())
return NULL_TIMESTAMP;
ResourceInfo info = ((File) file).getResourceInfo(false, false);
return info == null ? NULL_TIMESTAMP : info.getLocalSyncInfo();
}
/**
* @see IResourceTree#deletedFile(IFile)
*/
public void deletedFile(IFile file) {
Assert.isLegal(isValid);
// Do nothing if the resource doesn't exist.
if (!file.exists())
return;
try {
// Delete properties, generate marker deltas, and remove the node from the workspace tree.
((Resource) file).deleteResource(true, null);
} catch (CoreException e) {
String message = Policy.bind("resources.errorDeleting", file.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, file.getFullPath(), message, e);
failed(status);
}
}
/**
* @see IResourceTree#deletedFolder(IFolder)
*/
public void deletedFolder(IFolder folder) {
Assert.isLegal(isValid);
// Do nothing if the resource doesn't exist.
if (!folder.exists())
return;
try {
// Delete properties, generate marker deltas, and remove the node from the workspace tree.
((Resource) folder).deleteResource(true, null);
} catch (CoreException e) {
String message = Policy.bind("resources.errorDeleting", folder.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, folder.getFullPath(), message, e);
failed(status);
}
}
/**
* @see IResourceTree#deletedProject(IProject)
*/
public void deletedProject(IProject target) {
Assert.isLegal(isValid);
// Do nothing if the resource doesn't exist.
if (!target.exists())
return;
Project project = (Project) target;
Workspace workspace = (Workspace) project.getWorkspace();
// Delete properties, generate marker deltas, and remove the node from the workspace tree.
try {
project.deleteResource(false, null);
} catch (CoreException e) {
String message = Policy.bind("resources.errorDeleting", project.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, project.getFullPath(), message, e);
// log the status but don't return until we try and delete the rest of the project info
failed(status);
}
// Delete the project metadata.
try {
workspace.getMetaArea().delete(project);
} catch (CoreException e) {
String message = Policy.bind("resources.deleteMeta", project.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_METADATA, project.getFullPath(), message, e);
// log the status but don't return until we try and delete the rest of the project info
failed(status);
}
// Clear the history store.
try {
project.clearHistory(null);
} catch (CoreException e) {
String message = Policy.bind("history.problemsRemoving", project.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, project.getFullPath(), message, e);
failed(status);
}
}
/**
* This operation has failed for the given reason. Add it to this
* resource tree's status.
*/
public void failed(IStatus reason) {
Assert.isLegal(isValid);
status.add(reason);
}
/**
* Return <code>true</code> if there is a change in the name of the project.
*/
private boolean isNameChange(IProject project, IProjectDescription description) {
return !project.getName().equals(description.getName());
}
/**
* Return <code>true</code> if there is a change in the content area for the project.
*/
private boolean isContentChange(IProject project, IProjectDescription destinationDescription) {
IProjectDescription sourceDescription = ((Project) project).internalGetDescription();
if (sourceDescription.getLocation() == null || destinationDescription.getLocation() == null)
return true;
return !sourceDescription.getLocation().equals(destinationDescription.getLocation());
}
/**
* Returns <code>true</code> if we are doing a change in the case of the project name.
*/
private boolean isCaseChange(IProject project, IProjectDescription description) {
return !project.getName().equals(description.getName()) && project.getName().equalsIgnoreCase(description.getName());
}
/**
* @see IResourceTree#isSynchronized(IResource, int)
*/
public boolean isSynchronized(IResource resource, int depth) {
Assert.isLegal(isValid);
UnifiedTree tree = new UnifiedTree(resource);
String message = Policy.bind("resources.errorRefresh", resource.getFullPath().toString());
// FIXME: this visitor does too much work because it collects statuses for all
// children who are out of sync. We could optimize by returning early when discovering
// the first out of sync child.
CollectSyncStatusVisitor visitor = new CollectSyncStatusVisitor(message, new NullProgressMonitor());
try {
tree.accept(visitor, depth);
} catch (CoreException e) {
IStatus status = new ResourceStatus(IResourceStatus.FAILED_READ_LOCAL, resource.getFullPath(), message, e);
failed(status);
}
return !visitor.resourcesChanged();
}
/**
* @see IResourceTree#computeTimestamp(IFile)
*/
public long computeTimestamp(IFile file) {
Assert.isLegal(isValid);
if (!file.getProject().exists())
return NULL_TIMESTAMP;
return internalComputeTimestamp(file.getLocation().toOSString());
}
/**
* Return the timestamp of the file at the given location.
*/
protected long internalComputeTimestamp(String location) {
return CoreFileSystemLibrary.getLastModified(location);
}
/**
* @see IResourceTree#standardDeleteFile(IFile, int, IProgressMonitor)
*/
public void standardDeleteFile(IFile file, int updateFlags, IProgressMonitor monitor) {
Assert.isLegal(isValid);
internalDeleteFile(file, updateFlags, monitor);
}
/**
* Helper method for #standardDeleteFile. Returns a boolean indicating whether or
* not the delete was successful.
*/
private boolean internalDeleteFile(IFile file, int updateFlags, IProgressMonitor monitor) {
try {
String message = Policy.bind("resources.deleting", file.getFullPath().toString());
monitor.beginTask(message, Policy.totalWork);
// Do nothing if the file doesn't exist in the workspace.
if (!file.exists()) {
// Indicate that the delete was successful.
return true;
}
// If the file doesn't exist on disk then signal to the workspace to delete the
// file and return.
java.io.File fileOnDisk = file.getLocation().toFile();
if (!fileOnDisk.exists()) {
deletedFile(file);
// Indicate that the delete was successful.
return true;
}
boolean keepHistory = (updateFlags & IResource.KEEP_HISTORY) != 0;
boolean force = (updateFlags & IResource.FORCE) != 0;
// Add the file to the local history if requested by the user.
if (keepHistory)
addToLocalHistory(file);
monitor.worked(Policy.totalWork/4);
// We want to fail if force is false and the file is not synchronized with the
// local file system.
if (!force) {
boolean inSync = isSynchronized(file, IResource.DEPTH_ZERO);
// only want to fail if the file still exists.
if (!inSync && file.getLocation().toFile().exists()) {
message = Policy.bind("localstore.resourceIsOutOfSync", file.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.OUT_OF_SYNC_LOCAL, file.getFullPath(), message);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
}
}
monitor.worked(Policy.totalWork/4);
// Try to delete the file from the file system.
boolean success = fileOnDisk.delete();
monitor.worked(Policy.totalWork/4);
// If the file was successfully deleted from the file system the
// workspace tree should be updated accordingly. Otherwise
// we need to signal that a problem occurred.
if (success) {
deletedFile(file);
// Indicate that the delete was successful.
return true;
} else {
message = Policy.bind("resources.couldnotDelete", file.getLocation().toOSString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, file.getFullPath(), message);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
}
} finally {
monitor.done();
}
}
/**
* @see IResourceTree#standardDeleteFolder(IFolder, int, IProgressMonitor)
*/
public void standardDeleteFolder(IFolder folder, int updateFlags, IProgressMonitor monitor) {
Assert.isLegal(isValid);
try {
String message = Policy.bind("resources.deleting", folder.getFullPath().toString());
monitor.beginTask(message, Policy.totalWork);
// Do nothing if the folder doesn't exist in the workspace.
if (!folder.exists())
return;
// If the folder doesn't exist on disk then update the tree and return.
java.io.File folderOnDisk = folder.getLocation().toFile();
if (!folderOnDisk.exists()) {
deletedFolder(folder);
return;
}
// Check to see if we are synchronized with the local file system. If we are in sync then
// we can short circuit this operation and delete all the files on disk, otherwise we have
// to recursively try and delete them doing best-effort, thus leaving only the ones which
// were out of sync.
boolean force = (updateFlags & IResource.FORCE) != 0;
if (!force && !isSynchronized(folder, IResource.DEPTH_INFINITE)) {
// we are not in sync and force is false so delete via best effort
boolean deletedChildren = internalDeleteFolder(folder, updateFlags, monitor);
if (deletedChildren) {
deletedFolder(folder);
} else {
message = Policy.bind("resources.couldnotDelete", folder.getLocation().toOSString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, folder.getFullPath(), message);
failed(status);
}
return;
}
// Add the contents of the files to the local history if so requested by the user.
boolean keepHistory = (updateFlags & IResource.KEEP_HISTORY) != 0;
if (keepHistory)
addToLocalHistory(folder, IResource.DEPTH_INFINITE);
// If the folder was successfully deleted from the file system the
// workspace tree should be updated accordingly. Otherwise
// we need to signal that a problem occurred.
boolean success = Workspace.clear(folder.getLocation().toFile());
if (success) {
deletedFolder(folder);
} else {
message = Policy.bind("resources.couldnotDelete", folder.getLocation().toOSString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, folder.getFullPath(), message);
failed(status);
}
} finally {
monitor.done();
}
}
/**
* Add this resource and all child files to the local history. Only adds content for
* resources of type <code>IResource.FILE</code>.
*/
private void addToLocalHistory(IResource root, int depth) {
IResourceVisitor visitor = new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
if (resource.getType() == IResource.FILE)
addToLocalHistory((IFile) resource);
return true;
}
};
try {
root.accept(visitor, depth, false);
} catch (CoreException e) {
// We want to ignore any exceptions thrown by the history store because
// they aren't enough to fail the operation as a whole.
}
}
/**
* Helper method for #standardDeleteFolder. Returns a boolean indicating
* whether or not the deletion of this folder was successful. Does a best effort
* delete of this resource and its children.
*/
private boolean internalDeleteFolder(IFolder folder, int updateFlags, IProgressMonitor monitor) {
// Recursively delete each member of the folder.
IResource[] members = null;
try {
members = folder.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMembers", folder.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, folder.getFullPath(), message, e);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
}
boolean deletedChildren = true;
for (int i=0; i<members.length; i++) {
IResource child = members[i];
switch (child.getType()) {
case IResource.FILE:
deletedChildren &= internalDeleteFile((IFile) child, updateFlags, Policy.subMonitorFor(monitor, Policy.totalWork/members.length));
break;
case IResource.FOLDER:
deletedChildren &= internalDeleteFolder((IFolder) child, updateFlags, Policy.subMonitorFor(monitor, Policy.totalWork/members.length));
break;
}
}
// Check to see if the children were deleted ok. If there was a problem
// just return as the problem should have been logged by the recursive
// call to the child.
if (!deletedChildren) {
// Indicate that the delete was unsuccessful.
return false;
}
// Try to delete the folder from the local file system. This will fail
// if the folder is not empty. No need to check the force flag since this is
// an internal method and force is always false when we are here.
java.io.File folderOnDisk = folder.getLocation().toFile();
boolean success = folderOnDisk.delete();
if (!success && !folderOnDisk.exists()) {
// Indicate that the delete was successful.
success = true;
}
if (success) {
deletedFolder(folder);
// Indicate that the delete was successful.
return true;
} else {
String message = Policy.bind("resources.couldnotDelete", folder.getLocation().toOSString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, folder.getFullPath(), message);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
}
}
/**
* @see IResourceTree#standardDeleteProject(IProject, int, IProgressMonitor)
*/
public void standardDeleteProject(IProject project, int updateFlags, IProgressMonitor monitor) {
Assert.isLegal(isValid);
try {
String message = Policy.bind("resources.deleting", project.getFullPath().toString());
monitor.beginTask(message, Policy.totalWork);
// Do nothing if the project doesn't exist in the workspace tree.
if (!project.exists())
return;
boolean alwaysDeleteContent = (updateFlags & IResource.ALWAYS_DELETE_PROJECT_CONTENT) != 0;
// don't take force into account if we are always deleting the content
boolean force = alwaysDeleteContent ? true : (updateFlags & IResource.FORCE) != 0;
boolean neverDeleteContent = (updateFlags & IResource.NEVER_DELETE_PROJECT_CONTENT) != 0;
boolean success = true;
// Delete project content. Don't do anything if the user specified explicitly
// not to delete the project content.
if (alwaysDeleteContent || (project.isOpen() && !neverDeleteContent)) {
// Check to see if we are synchronized with the local file system. If we are in sync then
// we can short circuit this operation and delete all the files on disk, otherwise we have
// to recursively try and delete them doing best-effort, thus leaving only the ones which
// were out of sync.
if (!force && !isSynchronized(project, IResource.DEPTH_INFINITE)) {
// we are not in sync and force is false so delete via best effort
success = internalDeleteProject(project, updateFlags, monitor);
if (success) {
deletedProject(project);
} else {
message = Policy.bind("resources.couldnotDelete", project.getLocation().toOSString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, project.getFullPath(), message);
failed(status);
}
return;
}
// If the content area is in the default location then delete the directory and all its
// children. If it is specified by the user then leave the directory itself but delete the children.
java.io.File root = project.getLocation().toFile();
IProjectDescription description = ((Project) project).internalGetDescription();
if (description == null || description.getLocation() == null) {
success = Workspace.clear(root);
} else {
success = true;
String[] list = root.list();
// for some unknown reason, list() can return null.
// Just skip the children If it does.
if (list != null)
for (int i = 0; i < list.length; i++)
success &= Workspace.clear(new java.io.File(root, list[i]));
}
}
// deleting project content is 75% of the work
monitor.worked(Policy.totalWork*3/4);
// Signal that the workspace tree should be updated that the project
// has been deleted.
if (success) {
deletedProject(project);
} else {
message = Policy.bind("localstore.couldnotDelete", project.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, project.getFullPath(), message);
failed(status);
}
} finally {
monitor.done();
}
}
/**
* Helper method for moving the project content. Determines the content location
* based on the project description. (default location or user defined?)
*/
private void moveProjectContent(IProject source, IProjectDescription destDescription, int updateFlags, IProgressMonitor monitor) throws CoreException {
try {
IProjectDescription srcDescription = source.getDescription();
// If the locations are the same (and non-default) then there is nothing to do.
if (srcDescription.getLocation() != null && srcDescription.getLocation().equals(destDescription))
return;
IPath srcLocation = source.getLocation();
IPath destLocation = destDescription.getLocation();
// Use the default area if necessary for the destination. The source project
// should already have a location assigned to it.
if (destLocation == null)
destLocation = Platform.getLocation().append(destDescription.getName());
// Move the contents on disk.
moveInFileSystem(srcLocation.toFile(), destLocation.toFile(), updateFlags);
} finally {
monitor.done();
}
}
/**
* @see IResourceTree#standardMoveFile(IFile, IFile, int, IProgressMonitor)
*/
public void standardMoveFile(IFile source, IFile destination, int updateFlags, IProgressMonitor monitor) {
Assert.isLegal(isValid);
try {
String message = Policy.bind("resources.moving", source.getFullPath().toString());
monitor.beginTask(message, Policy.totalWork);
// These pre-conditions should all be ok but just in case...
if (!source.exists() || destination.exists() || !destination.getParent().isAccessible())
throw new IllegalArgumentException();
boolean force = (updateFlags & IResource.FORCE) != 0;
boolean keepHistory = (updateFlags & IResource.KEEP_HISTORY) != 0;
// If the file is not in sync with the local file system and force is false,
// then signal that we have an error.
if (force && !source.getLocation().toFile().exists()) {
message = Policy.bind("localstore.resourceIsOutOfSync", source.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.OUT_OF_SYNC_LOCAL, source.getFullPath(), message);
failed(status);
return;
} else {
boolean inSync = isSynchronized(source, IResource.DEPTH_ZERO);
if (!inSync) {
message = Policy.bind("localstore.resourceIsOutOfSync", source.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.OUT_OF_SYNC_LOCAL, source.getFullPath(), message);
failed(status);
return;
}
}
monitor.worked(Policy.totalWork/4);
// Add the file contents to the local history if requested by the user.
if (keepHistory)
addToLocalHistory(source);
monitor.worked(Policy.totalWork/4);
java.io.File sourceFile = source.getLocation().toFile();
java.io.File destFile = destination.getLocation().toFile();
// If the file was successfully moved in the file system then the workspace
// tree needs to be updated accordingly. Otherwise signal that we have an error.
try {
moveInFileSystem(sourceFile, destFile, updateFlags);
} catch (CoreException e) {
message = Policy.bind("localstore.couldnotMove", source.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.ERROR, source.getFullPath(), message, e);
failed(status);
return;
}
movedFile(source, destination);
updateMovedFileTimestamp(destination, computeTimestamp(destination));
monitor.worked(Policy.totalWork/4);
return;
} finally {
monitor.done();
}
}
/**
* @see IResourceTree#standardMoveFolder(IFolder, IFolder, int, IProgressMonitor)
*/
public void standardMoveFolder(IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor) {
Assert.isLegal(isValid);
try {
String message = Policy.bind("resources.moving", source.getFullPath().toString());
monitor.beginTask(message, Policy.totalWork);
// These pre-conditions should all be ok but just in case...
if (!source.exists() || destination.exists() || !destination.getParent().isAccessible())
throw new IllegalArgumentException();
// Check to see if we are synchronized with the local file system. If we are in sync then we can
// short circuit this method and do a file system only move. Otherwise we have to recursively
// try and move all resources, doing it in a best-effort manner.
boolean force = (updateFlags & IResource.FORCE) != 0;
if (!force && !isSynchronized(source, IResource.DEPTH_INFINITE)) {
message = "localstore.resourceIsOutOfSync";
IStatus status = new ResourceStatus(IResourceStatus.ERROR, source.getFullPath(), message);
failed(status);
return;
}
// keep history
boolean keepHistory = (updateFlags & IResource.KEEP_HISTORY) != 0;
if (keepHistory)
addToLocalHistory(source, IResource.DEPTH_INFINITE);
// Move the resources in the file system. Only the FORCE flag is valid here so don't
// have to worry about clearing the KEEP_HISTORY flag.
try {
moveInFileSystem(source.getLocation().toFile(), destination.getLocation().toFile(), updateFlags);
} catch (CoreException e) {
message = "Exception occured during file system move.";
IStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, destination.getFullPath(), message, e);
failed(status);
return;
}
boolean success = destination.getLocation().toFile().exists();
success &= !source.getLocation().toFile().exists();
if (success) {
movedFolderSubtree(source, destination);
updateTimestamps(destination);
} else {
message = Policy.bind("localstore.couldNotCreateFolder", destination.getLocation().toOSString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_WRITE_LOCAL, destination.getFullPath(), message);
failed(status);
}
} finally {
monitor.done();
}
}
/**
* Helper method to update all the timestamps in the tree to match
* those in the file system. Used after a #move.
*/
private void updateTimestamps(IResource root) {
IResourceVisitor visitor = new IResourceVisitor() {
public boolean visit(IResource resource) {
if (resource.getType() == IResource.FILE) {
IFile file = (IFile) resource;
long timestamp = computeTimestamp(file);
updateMovedFileTimestamp(file, timestamp);
}
return true;
}
};
try {
root.accept(visitor, IResource.DEPTH_INFINITE, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
} catch(CoreException e) {
// No exception should be thrown.
}
}
/**
* Does a best-effort delete on this resource and all its children.
*/
private boolean internalDeleteProject(IProject project, int updateFlags, IProgressMonitor monitor) {
// Recursively delete each member of the project.
IResource[] members = null;
try {
members = project.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
} catch (CoreException e) {
String message = Policy.bind("resources.errorMembers", project.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, project.getFullPath(), message, e);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
}
boolean deletedChildren = true;
for (int i=0; i<members.length; i++) {
IResource child = members[i];
switch (child.getType()) {
case IResource.FILE:
if (child.getName().equals(IProjectDescription.DESCRIPTION_FILE_NAME)) {
// ignore the .project file for now and delete it last
} else {
deletedChildren &= internalDeleteFile((IFile) child, updateFlags, Policy.subMonitorFor(monitor, Policy.totalWork/members.length));
}
break;
case IResource.FOLDER:
deletedChildren &= internalDeleteFolder((IFolder) child, updateFlags, Policy.subMonitorFor(monitor, Policy.totalWork/members.length));
break;
}
}
// Check to see if the children were deleted ok. If there was a problem
// just return as the problem should have been logged by the recursive
// call to the child.
if (deletedChildren) {
IResource file = project.findMember(IProjectDescription.DESCRIPTION_FILE_NAME);
if (file == null) {
// For some reason the .project file doesn't exist, so continue with the project
// deletion and pretend we deleted it already.
} else {
if (file.getType() != IResource.FILE) {
// We should never get here since the only reason we skipped it above was because
// it was a file named .project.
String message = Policy.bind("resources.couldnotDelete", file.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, file.getFullPath(), message);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
} else {
boolean deletedProjectFile = internalDeleteFile((IFile) file, updateFlags, Policy.monitorFor(null));
if (!deletedProjectFile) {
String message = Policy.bind("resources.couldnotDelete", file.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, file.getFullPath(), message);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
}
}
}
} else {
// Indicate that the delete was unsuccessful.
return false;
}
// If the content area is in the default location then delete the directory and all its
// children. If it is specified by the user then leave the directory itself but delete the children.
// No need to check the force flag since this is an internal method and by the time we
// get here we know that force is false.
java.io.File root = project.getLocation().toFile();
IProjectDescription description = ((Project) project).internalGetDescription();
// If we have a user-defined location delete the directory, otherwise just see if its empty
boolean success;
if (description == null || description.getLocation() == null) {
success = root.delete();
if (!success && !root.exists()) {
success = true;
}
} else {
String[] children = root.list();
success = children == null || children.length == 0;
}
if (success) {
deletedProject(project);
// Indicate that the delete was successful.
return true;
} else {
String message = Policy.bind("resources.couldnotDelete", project.getLocation().toOSString());
IStatus status = new ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, project.getFullPath(), message);
failed(status);
// Indicate that the delete was unsuccessful.
return false;
}
}
/**
* @see IResourceTree#standardMoveProject(IProject, IProjectDescription, int, IProgressMonitor)
*/
public void standardMoveProject(IProject source, IProjectDescription description, int updateFlags, IProgressMonitor monitor) {
Assert.isLegal(isValid);
try {
String message = Policy.bind("resources.moving", source.getFullPath().toString());
monitor.beginTask(message, Policy.totalWork);
// Double-check this pre-condition.
if (!source.isAccessible())
throw new IllegalArgumentException();
// If there is nothing to do on disk then signal to make the workspace tree
// changes.
if (!isContentChange(source, description)) {
movedProjectSubtree(source, description);
return;
}
// Check to see if we are synchronized with the local file system.
boolean force = (updateFlags & IResource.FORCE) != 0;
if (!force && !isSynchronized(source, IResource.DEPTH_INFINITE)) {
// FIXME: make this a best effort move?
message = Policy.bind("localstore.resourceIsOutOfSync", source.getFullPath().toString());
IStatus status = new ResourceStatus(IResourceStatus.OUT_OF_SYNC_LOCAL, source.getFullPath(), message);
failed(status);
return;
}
// Move the project content in the local file system.
try {
moveProjectContent(source, description, updateFlags, Policy.subMonitorFor(monitor, Policy.totalWork*3/4));
} catch (CoreException e) {
message = Policy.bind("localstore.couldnotMove", source.getFullPath().toString());
IStatus status = new ResourceStatus(IStatus.ERROR, source.getFullPath(), message, e);
failed(status);
return;
}
// If we got this far the project content has been moved on disk (if necessary)
// and we need to update the workspace tree.
movedProjectSubtree(source, description);
updateTimestamps(source.getWorkspace().getRoot().getProject(description.getName()));
} finally {
monitor.done();
}
}
/**
* Move the contents of the specified file from the source location to the destination location.
* If the source points to a directory then move that directory and all its contents.
*
* <code>IResource.FORCE</code> is the only valid flag.
*/
private void moveInFileSystem(java.io.File source, java.io.File destination, int updateFlags) throws CoreException {
Assert.isLegal(isValid);
FileSystemStore store = ((Resource) ResourcesPlugin.getWorkspace().getRoot()).getLocalManager().getStore();
boolean force = (updateFlags & IResource.FORCE) != 0;
store.move(source, destination, force, Policy.monitorFor(null));
}
/**
* @see IResourceTree#updateMovedFileTimestamp(IFile, long)
*/
public void updateMovedFileTimestamp(IFile file, long timestamp) {
Assert.isLegal(isValid);
// Do nothing if the file doesn't exist in the workspace tree.
if (!file.exists())
return;
// Update the timestamp in the tree.
ResourceInfo info = ((Resource) file).getResourceInfo(false, true);
// The info should never be null since we just checked that the resource exists in the tree.
((Resource) file).getLocalManager().updateLocalSync(info, timestamp, true);
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
afaa354e0e3cace8b5bf91b1924a6493ad57020e | a3c4c73b95c1bae2319da86f5625ccbdc89b5252 | /cagrid-dorian/cagrid-dorian-service/src/main/java/org/cagrid/dorian/service/util/Crypt.java | a4305b118dd6b9a4e3d1eb04e9b2c26cb8d38ff3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | NCIP/cagrid2 | 10e6f0fc77ee048a430c7c8f032d4dd6758f5dac | e9b5394c95b21430714435d7c3aff4c54f6c1460 | refs/heads/master | 2021-01-21T21:48:59.013062 | 2016-03-09T18:29:21 | 2016-03-09T18:29:21 | 10,062,288 | 4 | 1 | null | 2016-03-09T18:29:23 | 2013-05-14T18:45:34 | Java | UTF-8 | Java | false | false | 28,396 | java | package org.cagrid.dorian.service.util;
/**
* @author <A href="mailto:langella@bmi.osu.edu">Stephen Langella </A>
* @author <A href="mailto:oster@bmi.osu.edu">Scott Oster </A>
* @author <A href="mailto:hastings@bmi.osu.edu">Shannon Hastings </A>
* @version $Id: ArgumentManagerTable.java,v 1.2 2004/10/15 16:35:16 langella
* Exp $
*/
public class Crypt {
private static final int ITERATIONS = 16;
private static final int[] con_salt = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E,
0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A,
0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,};
private static final boolean[] shifts2 = {false, false, true, true, true, true, true, true, false, true, true,
true, true, true, true, false};
private static final int[][] skb = {
{
/*
* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6
*/
0x00000000, 0x00000010, 0x20000000, 0x20000010, 0x00010000, 0x00010010, 0x20010000, 0x20010010, 0x00000800,
0x00000810, 0x20000800, 0x20000810, 0x00010800, 0x00010810, 0x20010800, 0x20010810, 0x00000020,
0x00000030, 0x20000020, 0x20000030, 0x00010020, 0x00010030, 0x20010020, 0x20010030, 0x00000820,
0x00000830, 0x20000820, 0x20000830, 0x00010820, 0x00010830, 0x20010820, 0x20010830, 0x00080000,
0x00080010, 0x20080000, 0x20080010, 0x00090000, 0x00090010, 0x20090000, 0x20090010, 0x00080800,
0x00080810, 0x20080800, 0x20080810, 0x00090800, 0x00090810, 0x20090800, 0x20090810, 0x00080020,
0x00080030, 0x20080020, 0x20080030, 0x00090020, 0x00090030, 0x20090020, 0x20090030, 0x00080820,
0x00080830, 0x20080820, 0x20080830, 0x00090820, 0x00090830, 0x20090820, 0x20090830,},
{
/*
* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13
*/
0x00000000, 0x02000000, 0x00002000, 0x02002000, 0x00200000, 0x02200000, 0x00202000, 0x02202000, 0x00000004,
0x02000004, 0x00002004, 0x02002004, 0x00200004, 0x02200004, 0x00202004, 0x02202004, 0x00000400,
0x02000400, 0x00002400, 0x02002400, 0x00200400, 0x02200400, 0x00202400, 0x02202400, 0x00000404,
0x02000404, 0x00002404, 0x02002404, 0x00200404, 0x02200404, 0x00202404, 0x02202404, 0x10000000,
0x12000000, 0x10002000, 0x12002000, 0x10200000, 0x12200000, 0x10202000, 0x12202000, 0x10000004,
0x12000004, 0x10002004, 0x12002004, 0x10200004, 0x12200004, 0x10202004, 0x12202004, 0x10000400,
0x12000400, 0x10002400, 0x12002400, 0x10200400, 0x12200400, 0x10202400, 0x12202400, 0x10000404,
0x12000404, 0x10002404, 0x12002404, 0x10200404, 0x12200404, 0x10202404, 0x12202404,},
{
/*
* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20
*/
0x00000000, 0x00000001, 0x00040000, 0x00040001, 0x01000000, 0x01000001, 0x01040000, 0x01040001, 0x00000002,
0x00000003, 0x00040002, 0x00040003, 0x01000002, 0x01000003, 0x01040002, 0x01040003, 0x00000200,
0x00000201, 0x00040200, 0x00040201, 0x01000200, 0x01000201, 0x01040200, 0x01040201, 0x00000202,
0x00000203, 0x00040202, 0x00040203, 0x01000202, 0x01000203, 0x01040202, 0x01040203, 0x08000000,
0x08000001, 0x08040000, 0x08040001, 0x09000000, 0x09000001, 0x09040000, 0x09040001, 0x08000002,
0x08000003, 0x08040002, 0x08040003, 0x09000002, 0x09000003, 0x09040002, 0x09040003, 0x08000200,
0x08000201, 0x08040200, 0x08040201, 0x09000200, 0x09000201, 0x09040200, 0x09040201, 0x08000202,
0x08000203, 0x08040202, 0x08040203, 0x09000202, 0x09000203, 0x09040202, 0x09040203,},
{
/*
* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28
*/
0x00000000, 0x00100000, 0x00000100, 0x00100100, 0x00000008, 0x00100008, 0x00000108, 0x00100108, 0x00001000,
0x00101000, 0x00001100, 0x00101100, 0x00001008, 0x00101008, 0x00001108, 0x00101108, 0x04000000,
0x04100000, 0x04000100, 0x04100100, 0x04000008, 0x04100008, 0x04000108, 0x04100108, 0x04001000,
0x04101000, 0x04001100, 0x04101100, 0x04001008, 0x04101008, 0x04001108, 0x04101108, 0x00020000,
0x00120000, 0x00020100, 0x00120100, 0x00020008, 0x00120008, 0x00020108, 0x00120108, 0x00021000,
0x00121000, 0x00021100, 0x00121100, 0x00021008, 0x00121008, 0x00021108, 0x00121108, 0x04020000,
0x04120000, 0x04020100, 0x04120100, 0x04020008, 0x04120008, 0x04020108, 0x04120108, 0x04021000,
0x04121000, 0x04021100, 0x04121100, 0x04021008, 0x04121008, 0x04021108, 0x04121108,},
{
/*
* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6
*/
0x00000000, 0x10000000, 0x00010000, 0x10010000, 0x00000004, 0x10000004, 0x00010004, 0x10010004, 0x20000000,
0x30000000, 0x20010000, 0x30010000, 0x20000004, 0x30000004, 0x20010004, 0x30010004, 0x00100000,
0x10100000, 0x00110000, 0x10110000, 0x00100004, 0x10100004, 0x00110004, 0x10110004, 0x20100000,
0x30100000, 0x20110000, 0x30110000, 0x20100004, 0x30100004, 0x20110004, 0x30110004, 0x00001000,
0x10001000, 0x00011000, 0x10011000, 0x00001004, 0x10001004, 0x00011004, 0x10011004, 0x20001000,
0x30001000, 0x20011000, 0x30011000, 0x20001004, 0x30001004, 0x20011004, 0x30011004, 0x00101000,
0x10101000, 0x00111000, 0x10111000, 0x00101004, 0x10101004, 0x00111004, 0x10111004, 0x20101000,
0x30101000, 0x20111000, 0x30111000, 0x20101004, 0x30101004, 0x20111004, 0x30111004,},
{
/*
* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14
*/
0x00000000, 0x08000000, 0x00000008, 0x08000008, 0x00000400, 0x08000400, 0x00000408, 0x08000408, 0x00020000,
0x08020000, 0x00020008, 0x08020008, 0x00020400, 0x08020400, 0x00020408, 0x08020408, 0x00000001,
0x08000001, 0x00000009, 0x08000009, 0x00000401, 0x08000401, 0x00000409, 0x08000409, 0x00020001,
0x08020001, 0x00020009, 0x08020009, 0x00020401, 0x08020401, 0x00020409, 0x08020409, 0x02000000,
0x0A000000, 0x02000008, 0x0A000008, 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, 0x02020000,
0x0A020000, 0x02020008, 0x0A020008, 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, 0x02000001,
0x0A000001, 0x02000009, 0x0A000009, 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, 0x02020001,
0x0A020001, 0x02020009, 0x0A020009, 0x02020401, 0x0A020401, 0x02020409, 0x0A020409,},
{
/*
* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21
*/
0x00000000, 0x00000100, 0x00080000, 0x00080100, 0x01000000, 0x01000100, 0x01080000, 0x01080100, 0x00000010,
0x00000110, 0x00080010, 0x00080110, 0x01000010, 0x01000110, 0x01080010, 0x01080110, 0x00200000,
0x00200100, 0x00280000, 0x00280100, 0x01200000, 0x01200100, 0x01280000, 0x01280100, 0x00200010,
0x00200110, 0x00280010, 0x00280110, 0x01200010, 0x01200110, 0x01280010, 0x01280110, 0x00000200,
0x00000300, 0x00080200, 0x00080300, 0x01000200, 0x01000300, 0x01080200, 0x01080300, 0x00000210,
0x00000310, 0x00080210, 0x00080310, 0x01000210, 0x01000310, 0x01080210, 0x01080310, 0x00200200,
0x00200300, 0x00280200, 0x00280300, 0x01200200, 0x01200300, 0x01280200, 0x01280300, 0x00200210,
0x00200310, 0x00280210, 0x00280310, 0x01200210, 0x01200310, 0x01280210, 0x01280310,},
{
/*
* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28
*/
0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000002, 0x04000002, 0x00040002, 0x04040002, 0x00002000,
0x04002000, 0x00042000, 0x04042000, 0x00002002, 0x04002002, 0x00042002, 0x04042002, 0x00000020,
0x04000020, 0x00040020, 0x04040020, 0x00000022, 0x04000022, 0x00040022, 0x04040022, 0x00002020,
0x04002020, 0x00042020, 0x04042020, 0x00002022, 0x04002022, 0x00042022, 0x04042022, 0x00000800,
0x04000800, 0x00040800, 0x04040800, 0x00000802, 0x04000802, 0x00040802, 0x04040802, 0x00002800,
0x04002800, 0x00042800, 0x04042800, 0x00002802, 0x04002802, 0x00042802, 0x04042802, 0x00000820,
0x04000820, 0x00040820, 0x04040820, 0x00000822, 0x04000822, 0x00040822, 0x04040822, 0x00002820,
0x04002820, 0x00042820, 0x04042820, 0x00002822, 0x04002822, 0x00042822, 0x04042822,},};
private static final int[][] SPtrans = {
{
/*
* nibble 0
*/
0x00820200, 0x00020000, 0x80800000, 0x80820200, 0x00800000, 0x80020200, 0x80020000, 0x80800000, 0x80020200,
0x00820200, 0x00820000, 0x80000200, 0x80800200, 0x00800000, 0x00000000, 0x80020000, 0x00020000,
0x80000000, 0x00800200, 0x00020200, 0x80820200, 0x00820000, 0x80000200, 0x00800200, 0x80000000,
0x00000200, 0x00020200, 0x80820000, 0x00000200, 0x80800200, 0x80820000, 0x00000000, 0x00000000,
0x80820200, 0x00800200, 0x80020000, 0x00820200, 0x00020000, 0x80000200, 0x00800200, 0x80820000,
0x00000200, 0x00020200, 0x80800000, 0x80020200, 0x80000000, 0x80800000, 0x00820000, 0x80820200,
0x00020200, 0x00820000, 0x80800200, 0x00800000, 0x80000200, 0x80020000, 0x00000000, 0x00020000,
0x00800000, 0x80800200, 0x00820200, 0x80000000, 0x80820000, 0x00000200, 0x80020200,},
{
/*
* nibble 1
*/
0x10042004, 0x00000000, 0x00042000, 0x10040000, 0x10000004, 0x00002004, 0x10002000, 0x00042000, 0x00002000,
0x10040004, 0x00000004, 0x10002000, 0x00040004, 0x10042000, 0x10040000, 0x00000004, 0x00040000,
0x10002004, 0x10040004, 0x00002000, 0x00042004, 0x10000000, 0x00000000, 0x00040004, 0x10002004,
0x00042004, 0x10042000, 0x10000004, 0x10000000, 0x00040000, 0x00002004, 0x10042004, 0x00040004,
0x10042000, 0x10002000, 0x00042004, 0x10042004, 0x00040004, 0x10000004, 0x00000000, 0x10000000,
0x00002004, 0x00040000, 0x10040004, 0x00002000, 0x10000000, 0x00042004, 0x10002004, 0x10042000,
0x00002000, 0x00000000, 0x10000004, 0x00000004, 0x10042004, 0x00042000, 0x10040000, 0x10040004,
0x00040000, 0x00002004, 0x10002000, 0x10002004, 0x00000004, 0x10040000, 0x00042000,},
{
/*
* nibble 2
*/
0x41000000, 0x01010040, 0x00000040, 0x41000040, 0x40010000, 0x01000000, 0x41000040, 0x00010040, 0x01000040,
0x00010000, 0x01010000, 0x40000000, 0x41010040, 0x40000040, 0x40000000, 0x41010000, 0x00000000,
0x40010000, 0x01010040, 0x00000040, 0x40000040, 0x41010040, 0x00010000, 0x41000000, 0x41010000,
0x01000040, 0x40010040, 0x01010000, 0x00010040, 0x00000000, 0x01000000, 0x40010040, 0x01010040,
0x00000040, 0x40000000, 0x00010000, 0x40000040, 0x40010000, 0x01010000, 0x41000040, 0x00000000,
0x01010040, 0x00010040, 0x41010000, 0x40010000, 0x01000000, 0x41010040, 0x40000000, 0x40010040,
0x41000000, 0x01000000, 0x41010040, 0x00010000, 0x01000040, 0x41000040, 0x00010040, 0x01000040,
0x00000000, 0x41010000, 0x40000040, 0x41000000, 0x40010040, 0x00000040, 0x01010000,},
{
/*
* nibble 3
*/
0x00100402, 0x04000400, 0x00000002, 0x04100402, 0x00000000, 0x04100000, 0x04000402, 0x00100002, 0x04100400,
0x04000002, 0x04000000, 0x00000402, 0x04000002, 0x00100402, 0x00100000, 0x04000000, 0x04100002,
0x00100400, 0x00000400, 0x00000002, 0x00100400, 0x04000402, 0x04100000, 0x00000400, 0x00000402,
0x00000000, 0x00100002, 0x04100400, 0x04000400, 0x04100002, 0x04100402, 0x00100000, 0x04100002,
0x00000402, 0x00100000, 0x04000002, 0x00100400, 0x04000400, 0x00000002, 0x04100000, 0x04000402,
0x00000000, 0x00000400, 0x00100002, 0x00000000, 0x04100002, 0x04100400, 0x00000400, 0x04000000,
0x04100402, 0x00100402, 0x00100000, 0x04100402, 0x00000002, 0x04000400, 0x00100402, 0x00100002,
0x00100400, 0x04100000, 0x04000402, 0x00000402, 0x04000000, 0x04000002, 0x04100400,},
{
/*
* nibble 4
*/
0x02000000, 0x00004000, 0x00000100, 0x02004108, 0x02004008, 0x02000100, 0x00004108, 0x02004000, 0x00004000,
0x00000008, 0x02000008, 0x00004100, 0x02000108, 0x02004008, 0x02004100, 0x00000000, 0x00004100,
0x02000000, 0x00004008, 0x00000108, 0x02000100, 0x00004108, 0x00000000, 0x02000008, 0x00000008,
0x02000108, 0x02004108, 0x00004008, 0x02004000, 0x00000100, 0x00000108, 0x02004100, 0x02004100,
0x02000108, 0x00004008, 0x02004000, 0x00004000, 0x00000008, 0x02000008, 0x02000100, 0x02000000,
0x00004100, 0x02004108, 0x00000000, 0x00004108, 0x02000000, 0x00000100, 0x00004008, 0x02000108,
0x00000100, 0x00000000, 0x02004108, 0x02004008, 0x02004100, 0x00000108, 0x00004000, 0x00004100,
0x02004008, 0x02000100, 0x00000108, 0x00000008, 0x00004108, 0x02004000, 0x02000008,},
{
/*
* nibble 5
*/
0x20000010, 0x00080010, 0x00000000, 0x20080800, 0x00080010, 0x00000800, 0x20000810, 0x00080000, 0x00000810,
0x20080810, 0x00080800, 0x20000000, 0x20000800, 0x20000010, 0x20080000, 0x00080810, 0x00080000,
0x20000810, 0x20080010, 0x00000000, 0x00000800, 0x00000010, 0x20080800, 0x20080010, 0x20080810,
0x20080000, 0x20000000, 0x00000810, 0x00000010, 0x00080800, 0x00080810, 0x20000800, 0x00000810,
0x20000000, 0x20000800, 0x00080810, 0x20080800, 0x00080010, 0x00000000, 0x20000800, 0x20000000,
0x00000800, 0x20080010, 0x00080000, 0x00080010, 0x20080810, 0x00080800, 0x00000010, 0x20080810,
0x00080800, 0x00080000, 0x20000810, 0x20000010, 0x20080000, 0x00080810, 0x00000000, 0x00000800,
0x20000010, 0x20000810, 0x20080800, 0x20080000, 0x00000810, 0x00000010, 0x20080010,},
{
/*
* nibble 6
*/
0x00001000, 0x00000080, 0x00400080, 0x00400001, 0x00401081, 0x00001001, 0x00001080, 0x00000000, 0x00400000,
0x00400081, 0x00000081, 0x00401000, 0x00000001, 0x00401080, 0x00401000, 0x00000081, 0x00400081,
0x00001000, 0x00001001, 0x00401081, 0x00000000, 0x00400080, 0x00400001, 0x00001080, 0x00401001,
0x00001081, 0x00401080, 0x00000001, 0x00001081, 0x00401001, 0x00000080, 0x00400000, 0x00001081,
0x00401000, 0x00401001, 0x00000081, 0x00001000, 0x00000080, 0x00400000, 0x00401001, 0x00400081,
0x00001081, 0x00001080, 0x00000000, 0x00000080, 0x00400001, 0x00000001, 0x00400080, 0x00000000,
0x00400081, 0x00400080, 0x00001080, 0x00000081, 0x00001000, 0x00401081, 0x00400000, 0x00401080,
0x00000001, 0x00001001, 0x00401081, 0x00400001, 0x00401080, 0x00401000, 0x00001001,},
{
/*
* nibble 7
*/
0x08200020, 0x08208000, 0x00008020, 0x00000000, 0x08008000, 0x00200020, 0x08200000, 0x08208020, 0x00000020,
0x08000000, 0x00208000, 0x00008020, 0x00208020, 0x08008020, 0x08000020, 0x08200000, 0x00008000,
0x00208020, 0x00200020, 0x08008000, 0x08208020, 0x08000020, 0x00000000, 0x00208000, 0x08000000,
0x00200000, 0x08008020, 0x08200020, 0x00200000, 0x00008000, 0x08208000, 0x00000020, 0x00200000,
0x00008000, 0x08000020, 0x08208020, 0x00008020, 0x08000000, 0x00000000, 0x00208000, 0x08200020,
0x08008020, 0x08008000, 0x00200020, 0x08208000, 0x00000020, 0x00200020, 0x08008000, 0x08208020,
0x00200000, 0x08200000, 0x08000020, 0x00208000, 0x00008020, 0x08008020, 0x08200000, 0x00000020,
0x08208000, 0x00208020, 0x00000000, 0x08000000, 0x08200020, 0x00008000, 0x00208020}};
private static final int[] cov_2char = {0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A};
/**
* Constructor for the Crypt object
*/
private Crypt() {
}
/**
* Description of the Method
*
* @param b
* Description of the Parameter
* @return Description of the Return Value
*/
private static final int byteToUnsigned(byte b) {
int value = (int) b;
return ((value >= 0) ? value : value + 256);
}
/**
* Description of the Method
*
* @param b
* Description of the Parameter
* @param offset
* Description of the Parameter
* @return Description of the Return Value
*/
private static int fourBytesToInt(byte[] b, int offset) {
int value;
value = byteToUnsigned(b[offset++]);
value |= (byteToUnsigned(b[offset++]) << 8);
value |= (byteToUnsigned(b[offset++]) << 16);
value |= (byteToUnsigned(b[offset++]) << 24);
return value;
}
/**
* Description of the Method
*
* @param iValue
* Description of the Parameter
* @param b
* Description of the Parameter
* @param offset
* Description of the Parameter
*/
private static final void intToFourBytes(int iValue, byte[] b, int offset) {
b[offset++] = (byte) (iValue & 0xff);
b[offset++] = (byte) ((iValue >>> 8) & 0xff);
b[offset++] = (byte) ((iValue >>> 16) & 0xff);
b[offset++] = (byte) ((iValue >>> 24) & 0xff);
}
/**
* Description of the Method
*
* @param a
* Description of the Parameter
* @param b
* Description of the Parameter
* @param n
* Description of the Parameter
* @param m
* Description of the Parameter
* @param results
* Description of the Parameter
*/
private static final void PERM_OP(int a, int b, int n, int m, int[] results) {
int t;
t = ((a >>> n) ^ b) & m;
a ^= (t << n);
b ^= t;
results[0] = a;
results[1] = b;
}
/**
* Description of the Method
*
* @param a
* Description of the Parameter
* @param n
* Description of the Parameter
* @param m
* Description of the Parameter
* @return Description of the Return Value
*/
private static final int HPERM_OP(int a, int n, int m) {
int t;
t = ((a << (16 - n)) ^ a) & m;
a = a ^ t ^ (t >>> (16 - n));
return a;
}
/**
* Description of the Method
*
* @param key
* Description of the Parameter
* @return Description of the Return Value
*/
private static int[] des_set_key(byte[] key) {
int[] schedule = new int[ITERATIONS * 2];
int c = fourBytesToInt(key, 0);
int d = fourBytesToInt(key, 4);
int[] results = new int[2];
PERM_OP(d, c, 4, 0x0f0f0f0f, results);
d = results[0];
c = results[1];
c = HPERM_OP(c, -2, 0xcccc0000);
d = HPERM_OP(d, -2, 0xcccc0000);
PERM_OP(d, c, 1, 0x55555555, results);
d = results[0];
c = results[1];
PERM_OP(c, d, 8, 0x00ff00ff, results);
c = results[0];
d = results[1];
PERM_OP(d, c, 1, 0x55555555, results);
d = results[0];
c = results[1];
d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) | ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4));
c &= 0x0fffffff;
int s;
int t;
int j = 0;
for (int i = 0; i < ITERATIONS; i++) {
if (shifts2[i]) {
c = (c >>> 2) | (c << 26);
d = (d >>> 2) | (d << 26);
} else {
c = (c >>> 1) | (c << 27);
d = (d >>> 1) | (d << 27);
}
c &= 0x0fffffff;
d &= 0x0fffffff;
s = skb[0][c & 0x3f] | skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]
| skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]
| skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | ((c >>> 22) & 0x38)];
t = skb[4][d & 0x3f] | skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)] | skb[6][(d >>> 15) & 0x3f]
| skb[7][((d >>> 21) & 0x0f) | ((d >>> 22) & 0x30)];
schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff;
s = ((s >>> 16) | (t & 0xffff0000));
s = (s << 4) | (s >>> 28);
schedule[j++] = s & 0xffffffff;
}
return schedule;
}
/**
* Description of the Method
*
* @param L
* Description of the Parameter
* @param R
* Description of the Parameter
* @param S
* Description of the Parameter
* @param E0
* Description of the Parameter
* @param E1
* Description of the Parameter
* @param s
* Description of the Parameter
* @return Description of the Return Value
*/
private static final int D_ENCRYPT(int L, int R, int S, int E0, int E1, int[] s) {
int t;
int u;
int v;
v = R ^ (R >>> 16);
u = v & E0;
v = v & E1;
u = (u ^ (u << 16)) ^ R ^ s[S];
t = (v ^ (v << 16)) ^ R ^ s[S + 1];
t = (t >>> 4) | (t << 28);
L ^= (SPtrans[1][t & 0x3f] | SPtrans[3][(t >>> 8) & 0x3f] | SPtrans[5][(t >>> 16) & 0x3f]
| SPtrans[7][(t >>> 24) & 0x3f] | SPtrans[0][u & 0x3f] | SPtrans[2][(u >>> 8) & 0x3f]
| SPtrans[4][(u >>> 16) & 0x3f] | SPtrans[6][(u >>> 24) & 0x3f]);
return L;
}
/**
* Description of the Method
*
* @param schedule
* Description of the Parameter
* @param Eswap0
* Description of the Parameter
* @param Eswap1
* Description of the Parameter
* @return Description of the Return Value
*/
private static final int[] body(int[] schedule, int Eswap0, int Eswap1) {
int left = 0;
int right = 0;
int t = 0;
for (int j = 0; j < 25; j++) {
for (int i = 0; i < (ITERATIONS * 2); i += 4) {
left = D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule);
right = D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule);
}
t = left;
left = right;
right = t;
}
t = right;
right = (left >>> 1) | (left << 31);
left = (t >>> 1) | (t << 31);
left &= 0xffffffff;
right &= 0xffffffff;
int[] results = new int[2];
PERM_OP(right, left, 1, 0x55555555, results);
right = results[0];
left = results[1];
PERM_OP(left, right, 8, 0x00ff00ff, results);
left = results[0];
right = results[1];
PERM_OP(right, left, 2, 0x33333333, results);
right = results[0];
left = results[1];
PERM_OP(left, right, 16, 0x0000ffff, results);
left = results[0];
right = results[1];
PERM_OP(right, left, 4, 0x0f0f0f0f, results);
right = results[0];
left = results[1];
int[] out = new int[2];
out[0] = left;
out[1] = right;
return out;
}
public static final String crypt(String original) {
if (original.length() >= 1) {
StringBuffer salt = new StringBuffer();
int endIndex = original.length() - 1;
salt.append(original.substring(endIndex));
salt.append(original.substring(0, 1));
return crypt(salt.toString(), original);
} else {
return crypt("", original);
}
}
/**
* Description of the Method
*
* @param salt
* Description of the Parameter
* @param original
* Description of the Parameter
* @return Description of the Return Value
*/
public static final String crypt(String salt, String original) {
while (salt.length() < 2) {
salt += "A";
}
StringBuffer buffer = new StringBuffer(" ");
char charZero = salt.charAt(0);
char charOne = salt.charAt(1);
buffer.setCharAt(0, charZero);
buffer.setCharAt(1, charOne);
int Eswap0 = con_salt[(int) charZero];
int Eswap1 = con_salt[(int) charOne] << 4;
byte[] key = new byte[8];
for (int i = 0; i < key.length; i++) {
key[i] = (byte) 0;
}
for (int i = 0; (i < key.length) && (i < original.length()); i++) {
int iChar = (int) original.charAt(i);
key[i] = (byte) (iChar << 1);
}
int[] schedule = des_set_key(key);
int[] out = body(schedule, Eswap0, Eswap1);
byte[] b = new byte[9];
intToFourBytes(out[0], b, 0);
intToFourBytes(out[1], b, 4);
b[8] = 0;
for (int i = 2, y = 0, u = 0x80; i < 13; i++) {
for (int j = 0, c = 0; j < 6; j++) {
c <<= 1;
if (((int) b[y] & u) != 0) {
c |= 1;
}
u >>>= 1;
if (u == 0) {
y++;
u = 0x80;
}
buffer.setCharAt(i, (char) cov_2char[c]);
}
}
return (buffer.toString());
}
}
| [
"scott.oster@inventrio.com"
] | scott.oster@inventrio.com |
bf18dfd4e80337ea131fe9756f187bcbee450600 | 6bf3324db53db9e2789f488370275666de4386cc | /src/main/java/dev_comp/JokeObject.java | b601c33a7c5919d4f9c8182caf3cfd242e515d31 | [] | no_license | dev-comp/springclientservice | 27eddb55a68823d91719ac0b0893e0797f8f0dcf | f9ee4c2e0a28c6153b6f4e1884f7acd2bbe2fb6f | refs/heads/master | 2020-12-25T14:23:54.508201 | 2016-09-26T14:43:17 | 2016-09-26T14:43:17 | 67,804,284 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 731 | java | package dev_comp;
import java.util.List;
/**
* Created by a.kutakov on 22.09.2016.
*
*/
public class JokeObject {
private long count;
private String next;
private String previous;
private List<Joke> results;
public long getCount() {
return count;
}
public void setCount(long count) {
this.count = count;
}
public String getNext() {
return next;
}
public void setNext(String next) {
this.next = next;
}
public String getPrevious() {
return previous;
}
public void setPrevious(String previous) {
this.previous = previous;
}
public List<Joke> getResults() {
return results;
}
public void setResults(List<Joke> results) {
this.results = results;
}
}
| [
"a.kutakov@bftcom.com"
] | a.kutakov@bftcom.com |
b49252ac557de8f2f1e1a10a373e10527b317065 | f17620d057584dc8938fc29b66121205ac54cc2f | /streams/streams/com_1/java8/page542/DVDInfo.java | bfe200293ba3a52297c7c8a25d4d2ef1da795919 | [] | no_license | pritishpadhan70/java8 | 3357f2ae9b2d99ffff9a213569129895c400c067 | c14ed1f508e47752182cb8de78f229faf82816dd | refs/heads/master | 2023-06-25T17:52:21.891739 | 2021-07-29T07:26:45 | 2021-07-29T07:26:45 | 390,637,898 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 740 | java | package streams.com_1.java8.page542;
public class DVDInfo {
private String title;
private String genre;
private String leadActor;
public DVDInfo(String title, String genre, String leadActor) {
super();
this.title = title;
this.genre = genre;
this.leadActor = leadActor;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public String getLeadActor() {
return leadActor;
}
public void setLeadActor(String leadActor) {
this.leadActor = leadActor;
}
@Override
public String toString() {
return title + " / " + genre + " / " + leadActor;
}
}
| [
"pritishpadhan70@gmail.com"
] | pritishpadhan70@gmail.com |
61522bfef05e0a074bbd2e0ae1b7c3a96604d263 | 9f90b0106715b4f7c21f5cf06b0c83fc7f21dbb8 | /src/main/java/Stock.java | 1b277be4a8c00eaf063f3463914b08ae7db6905c | [] | no_license | michaelnkunim/java-test | dc586798c7a8f4d8df807843e4c6ccf0d56fee94 | 74c18ec29be45f950c6c68c76f9e41987e0c3df7 | refs/heads/master | 2023-09-05T23:38:10.529386 | 2021-10-14T07:05:11 | 2021-10-14T07:05:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | public class Stock extends Product {
String ticker;
double price;
private final ProductPricingService productPricingService;
public Stock(String ID, String exchange, String ticker, ProductPricingService productPricingService) {
super(ID, exchange);
this.ticker = ticker;
this.productPricingService = productPricingService;
}
public double getPrice() {
price = productPricingService.price(this.exchange,this.ticker);
return price;
}
public String getTicker() {
return ticker;
}
public void setTicker(String ticker) {
this.ticker = ticker;
}
public void setPrice(double price) {
this.price = price;
}
}
| [
"mokohvicctory@gmail.com"
] | mokohvicctory@gmail.com |
09aefaac6a8029cbc0b550f673997d1df32906e1 | 7fc9b801823ab4bca889f861dc4b99ad0fa0b29a | /src/android/QNotificationListenerService.java | c73eb2a9074da0635db4081b8fb9175616478cfd | [
"Apache-2.0"
] | permissive | Qbix/cordova-plugin-hello | b8d9a9d60946a0076f814c2b3b98e6e9169e9cae | e831fb307c85cf9bf874256d92a8a6290352bc65 | refs/heads/master | 2020-05-25T17:32:44.326606 | 2020-03-15T15:24:15 | 2020-03-15T15:24:15 | 187,911,462 | 0 | 0 | null | 2019-05-21T20:48:47 | 2019-05-21T20:48:47 | null | UTF-8 | Java | false | false | 3,969 | java | package com.qbix.sound.notification;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.IBinder;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import java.io.IOException;
import static android.provider.Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.text.TextUtils;
import android.provider.Settings;
public class QNotificationListenerService extends NotificationListenerService {
private MediaPlayer player;
@Override
public IBinder onBind(Intent intent) {
return super.onBind(intent);
}
@Override
public void onNotificationPosted(StatusBarNotification sbn){
boolean isMatch = matchNotificationCode(sbn);
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(this, Uri.parse(""));
mp.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mp.start();
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn){
boolean isMatch = matchNotificationCode(sbn);
}
private boolean matchNotificationCode(StatusBarNotification sbn) {
String packageName = sbn.getPackageName();
return false;
}
// private AlertDialog enableNotificationListenerAlertDialog;
// private static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
// if(!isNotificationServiceEnabled()){
// enableNotificationListenerAlertDialog = buildNotificationServiceAlertDialog();
// enableNotificationListenerAlertDialog.show();
// }
//
// /**
// * Is Notification Service Enabled.
// * Verifies if the notification listener service is enabled.
// * Got it from: https://github.com/kpbird/NotificationListenerService-Example/blob/master/NLSExample/src/main/java/com/kpbird/nlsexample/NLService.java
// * @return True if enabled, false otherwise.
// */
// private boolean isNotificationServiceEnabled(){
// String pkgName = getPackageName();
// final String flat = Settings.Secure.getString(getContentResolver(),
// ENABLED_NOTIFICATION_LISTENERS);
// if (!TextUtils.isEmpty(flat)) {
// final String[] names = flat.split(":");
// for (int i = 0; i < names.length; i++) {
// final ComponentName cn = ComponentName.unflattenFromString(names[i]);
// if (cn != null) {
// if (TextUtils.equals(pkgName, cn.getPackageName())) {
// return true;
// }
// }
// }
// }
// return false;
// }
//
// private AlertDialog buildNotificationServiceAlertDialog(){
// AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
// alertDialogBuilder.setTitle(R.string.notification_listener_service);
// alertDialogBuilder.setMessage(R.string.notification_listener_service_explanation);
// alertDialogBuilder.setPositiveButton(R.string.yes,
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// startActivity(new Intent(ACTION_NOTIFICATION_LISTENER_SETTINGS));
// }
// });
// alertDialogBuilder.setNegativeButton(R.string.no,
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// // If you choose to not enable the notification listener
// // the app. will not work as expected
// }
// });
// return(alertDialogBuilder.create());
// }
}
| [
"igor.martsekha@gmail.com"
] | igor.martsekha@gmail.com |
ab20951bbaa9ea5a0fb8f7e546f7b58b17ad2834 | 5da2534bc582022c54d50c20c93a7c1872ac37d5 | /metrics/src/main/java/com/facebook/battery/metrics/network/NetworkMetricsCollector.java | 966029c6265072cc38f071d789d4513241e32bea | [
"MIT"
] | permissive | z4zzaman/Battery-Metrics | 4ba3b4b2bc7d2c8c87616570e812880d12ebad6c | 52941f03f7cc02b599b172208fbf719162e8b51e | refs/heads/master | 2020-08-03T03:33:22.464613 | 2019-09-13T02:38:47 | 2019-09-13T02:41:30 | 211,612,867 | 1 | 0 | MIT | 2019-09-29T06:13:18 | 2019-09-29T06:13:18 | null | UTF-8 | Java | false | false | 3,778 | java | /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*/
package com.facebook.battery.metrics.network;
import static com.facebook.battery.metrics.network.NetworkBytesCollector.BG;
import static com.facebook.battery.metrics.network.NetworkBytesCollector.FG;
import static com.facebook.battery.metrics.network.NetworkBytesCollector.MOBILE;
import static com.facebook.battery.metrics.network.NetworkBytesCollector.RX;
import static com.facebook.battery.metrics.network.NetworkBytesCollector.TX;
import static com.facebook.battery.metrics.network.NetworkBytesCollector.WIFI;
import android.content.Context;
import com.facebook.battery.metrics.core.SystemMetricsCollector;
import com.facebook.battery.metrics.core.SystemMetricsLogger;
import com.facebook.infer.annotation.ThreadSafe;
import java.util.Arrays;
/**
* Records data transferred by the current application, broken down by type of network (radio vs
* wifi) and bytes received and transmitted.
*
* <p>This tries to use a qtaguid file if available, but otherwise falls back to TrafficStats with
* manual instrumentation for guessing which type of network is active.
*
* <p>See {@link EnhancedNetworkMetricsCollector} for distinguishing between foreground/background
* app states as well.
*/
@ThreadSafe
public class NetworkMetricsCollector extends SystemMetricsCollector<NetworkMetrics> {
private static final String TAG = "NetworkMetricsCollector";
private boolean mIsValid = true;
private final NetworkBytesCollector mCollector;
private final long[] mBytes;
private final long[] mPrevBytes;
public NetworkMetricsCollector(Context context) {
mCollector = NetworkBytesCollector.create(context);
mBytes = NetworkBytesCollector.createByteArray();
mPrevBytes = NetworkBytesCollector.createByteArray();
}
@Override
@ThreadSafe(enableChecks = false)
public synchronized boolean getSnapshot(NetworkMetrics snapshot) {
// Once the value has decreased, the underlying value has almost certainly reset and all current
// snapshots are invalidated. Disable this collector.
if (!mIsValid || !mCollector.getTotalBytes(mBytes)) {
return false;
}
mIsValid = ensureBytesIncreased(mBytes, mPrevBytes);
if (!mIsValid) {
return false;
}
boolean supportsBgDetection = mCollector.supportsBgDistinction();
resetMetrics(snapshot);
addMetricsFromBytes(snapshot, mBytes, FG);
if (supportsBgDetection) {
addMetricsFromBytes(snapshot, mBytes, BG);
}
return true;
}
static boolean ensureBytesIncreased(long[] currentBytes, long[] previousBytes) {
for (int i = 0; i < currentBytes.length; i++) {
if (currentBytes[i] < previousBytes[i]) {
SystemMetricsLogger.wtf(
TAG,
"Network Bytes decreased from "
+ Arrays.toString(previousBytes)
+ " to "
+ Arrays.toString(currentBytes));
return false;
}
}
System.arraycopy(currentBytes, 0, previousBytes, 0, currentBytes.length);
return true;
}
static void addMetricsFromBytes(NetworkMetrics metrics, long[] bytes, int fgBgBit) {
metrics.mobileBytesTx += bytes[MOBILE | TX | fgBgBit];
metrics.mobileBytesRx += bytes[MOBILE | RX | fgBgBit];
metrics.wifiBytesTx += bytes[WIFI | TX | fgBgBit];
metrics.wifiBytesRx += bytes[WIFI | RX | fgBgBit];
}
static void resetMetrics(NetworkMetrics metrics) {
metrics.mobileBytesTx = 0;
metrics.mobileBytesRx = 0;
metrics.wifiBytesTx = 0;
metrics.wifiBytesRx = 0;
}
@Override
public NetworkMetrics createMetrics() {
return new NetworkMetrics();
}
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
dd5d9172b214ef44635e56de376b9ff798ee5906 | 590289e0b4a0bf4359dc15b3ceba36bdf23f1b7c | /MinnieTwitter/src/sapphire/appexamples/minnietwitter/device/twimight/activities/ShowUserTweetListActivity.java | edf6f4670cc3ae87a00a95907920f5961c610a31 | [] | no_license | fkdl/agate_applications | d58cfdf5533742d4e8b91b745a159a99aa74a827 | b64b546050e5c3937eb357beb7e121ee6374e1b4 | refs/heads/master | 2020-03-24T19:53:43.767032 | 2016-05-05T18:57:29 | 2016-05-05T18:57:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,013 | java | /*******************************************************************************
* Copyright (c) 2011 ETH Zurich.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Paolo Carta - Implementation
* Theus Hossmann - Implementation
* Dominik Schatzmann - Message specification
******************************************************************************/
package sapphire.appexamples.minnietwitter.device.twimight.activities;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import sapphire.appexamples.minnietwitter.device.twimight.R;
import sapphire.appexamples.minnietwitter.device.twimight.fragments.TweetListFragment;
/**
* Shows the most recent tweets of a user
* @author thossmann
*
*/
public class ShowUserTweetListActivity extends TwimightBaseActivity{
private static final String TAG = "ShowUserTweetListActivity";
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//System.out.println("In ShowUserTweetListActivity");
if(!getIntent().hasExtra("screenname")) finish();
setContentView(R.layout.main);
String screenname = getIntent().getStringExtra("screenname");
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
TweetListFragment tlf = new TweetListFragment(TweetListFragment.USER_TWEETS);
Bundle bundle = new Bundle();
bundle.putString(TweetListFragment.USER_ID, screenname);
tlf.setArguments(bundle);
fragmentTransaction.add(R.id.rootRelativeLayout,tlf);
fragmentTransaction.commit();
}
}
| [
"aaasz@cs.washington.edu"
] | aaasz@cs.washington.edu |
9069fc9882854d5cee535026d3d895307986009f | 0ad4acef4a15663b1c2498089c0c9127fea4e203 | /src/main/java/com/lgy/learngit/bean/Employee.java | b2cd8a1a8ddea972bf47034fbbc5f700d60cd350 | [] | no_license | lgykuuga/learngit | 88f103740d4711b5084694c4ad8cb6e9f7f6aa7d | 870638677589731078da2c0e82f5f70330b06cbc | refs/heads/master | 2021-06-18T21:32:03.559550 | 2021-04-06T03:30:31 | 2021-04-06T03:30:31 | 194,051,240 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 871 | java | package com.lgy.learngit.bean;
public class Employee {
private Integer id;
private String lastName;
private Integer gender;
private String email;
private Integer dId;
public void setId(Integer id) {
this.id = id;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public void setEmail(String email) {
this.email = email;
}
public void setdId(Integer dId) {
this.dId = dId;
}
public Integer getId() {
return id;
}
public String getLastName() {
return lastName;
}
public Integer getGender() {
return gender;
}
public String getEmail() {
return email;
}
public Integer getdId() {
return dId;
}
}
| [
"645241426@qq.com"
] | 645241426@qq.com |
c3857058e40b5be008a256d1174de90300e91283 | aa72f27bcd140accb5da5efa2944fccc331e2ff4 | /src/com/hm/InAndMarkSys/service/imp/GysServiceImp.java | c4f832b52d984eb555d8de2427eebd142f6e54fa | [] | no_license | qingyang9527/InAndMarkSys | 138b72446a97a8ca16c7ea26c21b3eed288d1d39 | 596f533de798cf77ff23a88d2dcfb28ef9802d1b | refs/heads/master | 2021-01-25T06:56:08.782081 | 2017-06-19T05:46:13 | 2017-06-19T05:46:13 | 93,628,244 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 929 | java | package com.hm.InAndMarkSys.service.imp;
import java.util.List;
import com.hm.InAndMarkSys.dao.GysDao;
import com.hm.InAndMarkSys.model.TbGys;
import com.hm.InAndMarkSys.service.GysService;
public class GysServiceImp implements GysService {
private GysDao gysDao;
public void setGysDao(GysDao gysDao) {
this.gysDao = gysDao;
}
@Override
public void save(TbGys tbGys) {
this.gysDao.save(tbGys);
}
@Override
public void delete(String id) {
this.gysDao.delete(id);
}
@Override
public void update(TbGys tbGys) {
this.gysDao.update(tbGys);
}
@Override
public List queryPage(int currentPage, int pageSize) {
return this.gysDao.queryPage(currentPage, pageSize);
}
@Override
public List get(String id) {
return this.gysDao.get(id);
}
@Override
public int getTotalSize() {
return this.gysDao.getTotalSize();
}
@Override
public List<TbGys> findAll() {
return this.gysDao.findAll();
}
}
| [
"2419744266@qq.com"
] | 2419744266@qq.com |
0e21d2dbb6c38dd724d4f2794bf1e05366a41a34 | 92ab715e7dc3480dcfcad351264734c5bbdc4119 | /quant-facade/src/main/java/com/slf/quant/facade/service/strategy/QuantAvgConfigService.java | fb4ce5c7bc6013e81a0f54e37a8f65d694a0519b | [] | no_license | Fzkbnb/slfquant | df24d03ba9d9cee6e29333a3f368259db841d422 | 6c78c4ad7e063e00d60e8dc9a43d956b76e48068 | refs/heads/master | 2023-06-05T19:39:44.921360 | 2021-06-21T07:53:55 | 2021-06-21T07:53:55 | 379,779,786 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 460 | java | /*
* Copyright 2017 BLOCAIN, Inc. All rights reserved. com.blocain
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.slf.quant.facade.service.strategy;
import com.slf.quant.facade.bean.BaseService;
import com.slf.quant.facade.entity.strategy.QuantAvgConfig;
public interface QuantAvgConfigService extends BaseService<QuantAvgConfig>
{
void changeStatus(Long id, int i);
void changeAllStatus(int i);
}
| [
"1137238400@qq.com"
] | 1137238400@qq.com |
49e0580e3c1556e9fed4c51ac3977873191724db | 40b6e98e3b6b043d62a43a60976845dc029f38aa | /billmaker-backend/src/main/java/com/ecse428/billmaker/dto/CategoryDto.java | 0ee009465f4302a46fc39574b82df08f7150e4dd | [] | no_license | bobqian1007/ECSE428-BillMaker | b06053cdb4e1f2a7fc96ff6cb486910fb233f5e4 | a97d0e5078909e97cf58d8817b2d7986af090d7e | refs/heads/master | 2023-03-28T09:08:48.559496 | 2021-03-28T03:10:45 | 2021-03-28T03:10:45 | 333,290,924 | 0 | 0 | null | 2021-03-28T03:11:04 | 2021-01-27T03:23:38 | Java | UTF-8 | Java | false | false | 700 | java | package com.ecse428.billmaker.dto;
import java.util.HashSet;
import java.util.Set;
import com.ecse428.billmaker.model.Category;
import com.ecse428.billmaker.model.Expense;
public class CategoryDto {
private String name;
private Set<Expense> expenses;
public CategoryDto(String name, Set<Expense> expenses) {
this.name = name;
this.expenses = expenses;
}
public CategoryDto(Category c) {
this.name = c.getName();
HashSet<Expense> list = new HashSet<Expense>();
list.add(c.getExpense());
this.expenses = list;
}
public String getName() { return name; }
public Set<Expense> getExpenses() { return expenses; }
}
| [
"cuizhengyu@hotmail.com"
] | cuizhengyu@hotmail.com |
d76c36bc89d7f9d6453bb2a1e435054644b0b653 | 48ee226d0950be84a6ee41e1b94b7de5507050df | /src/main/java/com/klimkin/thought/repos/MessageRepo.java | 827eab1171feb0ade3d44300f90bb76b0d517460 | [] | no_license | anton-kli/thoughts | 82b1afc543b33d8534d63a4bf532ca6541ba403b | f4e7689d2057ba09600060930e9fc4aa190c6432 | refs/heads/master | 2021-01-02T20:15:40.903065 | 2020-02-11T20:35:14 | 2020-02-11T20:35:14 | 239,781,819 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 279 | java | package com.klimkin.thought.repos;
import com.klimkin.thought.domain.Message;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface MessageRepo extends CrudRepository<Message, Integer> {
List<Message>findByTag(String tag);
}
| [
"a.s.klimkin@gmail.com"
] | a.s.klimkin@gmail.com |
f3b1e6a2fbee9832ac67e8a04f02a9577167eaca | 5e42fe4ca6ca1b9532b81085ca085274d0a5b734 | /app/src/main/java/eu/rekisoft/android/medium_example/MainActivity.java | 4466c6cbfed6496856d102462c81fa8e37f7bbc3 | [
"Apache-2.0"
] | permissive | rekire/MediumExample | 49abdacc1d8a9dc1e0a33b2888d0d98fb9fd5ee6 | c5b920f50c01c8a2f24510eea69b76dc8bd5af21 | refs/heads/master | 2020-04-02T04:18:36.049407 | 2016-07-16T12:47:53 | 2016-07-16T12:47:53 | 63,479,351 | 4 | 1 | null | null | null | null | UTF-8 | Java | false | false | 347 | java | package eu.rekisoft.android.medium_example;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
| [
"git@reki.re"
] | git@reki.re |
b98f1f3b22222753787774521af831f032914afa | 2b7264dc143abdbef8aa9e929433599fffb9f038 | /app/src/main/java/com/iscool/edward/stockmarkettwitter/ArticleActivity.java | a37f515f860f80455be373b0a004f582fbbffd7f | [] | no_license | st4rgut22/SmarterInvesting | f2262e19c64771d112e82442f433bbe1be3ab368 | d82fb4035dbbcff3c88d000d0d8721be799526ec | refs/heads/master | 2020-03-28T19:58:44.455788 | 2018-10-02T21:43:10 | 2018-10-02T21:43:10 | 149,027,189 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,747 | java | package com.iscool.edward.stockmarkettwitter;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.iscool.edward.stockmarkettwitter.database.PlayerSchema;
import java.util.ArrayList;
public class ArticleActivity extends AppCompatActivity{
private TextView wikiArticle;
private Button quizMe;
private Button submitMe;
private LinearLayout answer;
private String quiz;
private String paragraph;
private ArrayList<String> answerList;
SqlLite sqlLiteHelper;
int quizzes;
Context mContext;
String title;
String quizUUID;
ArrayList<String> userAnswers = new ArrayList<String>();
private static String quizId = "com.iscool.edward.stockmarkettwitter.uuid";
private static String quizCount = "com.iscool.edward.stockmarkettwitter.quizCount";
private static String reading = "com.iscool.edward.stockmarkettwitter.readId";
public static Intent newIntent(Context mContext,String uuid,String readId,int quizC){
Intent i = new Intent(mContext,ArticleActivity.class);
i.putExtra(quizId,uuid);
i.putExtra(reading,readId);
i.putExtra(quizCount,quizC);
return i;
}
@Override
public void onCreate(Bundle SavedInstanceState){
super.onCreate(SavedInstanceState);
setContentView(R.layout.activity_article);
mContext=this;
wikiArticle = (TextView)findViewById(R.id.wikiArticle);
sqlLiteHelper = new SqlLite(mContext);
sqlLiteHelper.getWritableDatabase();
// article = new Article(sqlLiteHelper,wikiArticle,this,title);
//returns reading identifier, which we pass to score activity
quizMe = (Button)findViewById(R.id.takeQuiz);
submitMe = (Button)findViewById(R.id.submitQuiz);
answer = (LinearLayout) findViewById(R.id.answerField);
Intent intent = getIntent();
quizUUID = intent.getStringExtra(quizId);
String readUUID = intent.getStringExtra(reading);
quizzes = intent.getIntExtra(quizCount,0);
//create a pragraph
paragraph = Article.getParagraph(sqlLiteHelper,wikiArticle,quizUUID);
//opening a new database, creates a new database file if it does not already exist
//prompt user for title
quizMe.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
createAnswerFields();
}
});
submitMe.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
//record each response
//compare answers
storeAnswers();
float correct = calculateCorrect();
float score = calculateScore(correct,readUUID,quizUUID);
//new activity
Intent intent = ArticleScoreActivity.newIntent(mContext,score,correct,readUUID,quizUUID);
startActivity(intent);
}
});
}
public void createAnswerFields(){
quizMe.setVisibility(View.GONE);
submitMe.setVisibility(View.VISIBLE);
quiz = Article.createQuiz(paragraph);
wikiArticle.setText(Html.fromHtml(quiz,Html.FROM_HTML_MODE_LEGACY));
answerList = Article.getAnswer(sqlLiteHelper,quizUUID);
//adding answer fields
for (int i=0;i<answerList.size();i++){
EditText editText = new EditText(mContext);
editText.setText(Integer.toString(i+1));
answer.addView(editText);
}
}
public void storeAnswers(){
//populates user answers with answers
for (int i=0;i<answer.getChildCount();i++){
if (answer.getChildAt(i) instanceof EditText){
EditText value = (EditText) answer.getChildAt(i);
String answer = value.getText().toString();
userAnswers.add(answer);
}
}
}
public void restoreAnswers(ArrayList<String>userAnswers) {
for (int i = 0; i < answer.getChildCount(); i++) {
if (answer.getChildAt(i) instanceof EditText) {
EditText value = (EditText) answer.getChildAt(i);
value.setText(userAnswers.get(i));
}
}
}
@Override
protected void onSaveInstanceState(Bundle outState){
storeAnswers(); //save the answers on rotation
outState.putStringArrayList("userAnswerStrings",userAnswers);
super.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle inState){
userAnswers = inState.getStringArrayList("userAnswerStrings");
if (userAnswers.size()!=0) {
createAnswerFields();
restoreAnswers(userAnswers);
super.onSaveInstanceState(inState);
}
}
public float calculateCorrect() {
float total = answerList.size();
float correct = 0;
for (int i = 0; i < total; i++) {
if (answerList.get(i).toLowerCase().equals(userAnswers.get(i).toLowerCase())) {
correct++;
}
}
return correct;
}
public float calculateScore(float correct,String readUUID,String quizUUID){
//answer list will always be the same as user answer list
float score;
float total = answerList.size();
score = Math.round((correct/total)*100);
//adds score to quiz, and prevents the quiz from being taken again
Article.addScore(sqlLiteHelper,quizUUID,readUUID,paragraph,score);
int readingTotal = Article.incProgress(sqlLiteHelper,readUUID);
System.out.println("total quizzes " + quizzes);
System.out.println("readings completed " + readingTotal);
if (quizzes==readingTotal){
//if we have finished all the readings decrement topic list
Cursor c = sqlLiteHelper.allRows(PlayerSchema.PlayerTable.NAME);
if(c.moveToFirst()) {
int topicProgress = c.getInt(c.getColumnIndex(PlayerSchema.PlayerTable.Cols.TOPIC));
topicProgress--;
ContentValues cv = new ContentValues();
cv.put("topic",topicProgress);
sqlLiteHelper.updateRow(PlayerSchema.PlayerTable.NAME,cv,null,null);
}
}
return score;
}
}
| [
"edwardcox@new-host-4.home"
] | edwardcox@new-host-4.home |
5a0fc146eb3e0060b72f40abf8bbc798c6c15339 | 6dbf091748a9a19e0f343cd9be17db6929eef7d9 | /code practice/BitMagic/Easy/TurnOffK.java | 65458a99930f8047a6d266f3f933c270c53a7e22 | [] | no_license | hbtidotgkb/mindworkout | 80aad5bf0c2e51b7c7d6b1542db7214bdf8928b1 | f4df7fe986beb44786434a2db44ceeee467b3a62 | refs/heads/master | 2022-06-29T11:03:58.533292 | 2021-09-29T03:54:40 | 2021-09-29T03:54:40 | 149,971,165 | 0 | 0 | null | 2022-06-21T04:18:36 | 2018-09-23T09:45:28 | Java | WINDOWS-1252 | Java | false | false | 1,078 | java | package BitMagic;
/**
* How to turn off a particular bit in a number? Difficulty Level: Rookie
*
* Given a number n and a value k, turn of the k’th bit in n.
*
* @author g.bhardwaj
*
*/
public class TurnOffK {
public static void main(String[] args) {
int n = 15;
int k = 4;
int newNo = turnOffKMyWay(2, 1);
System.out.println(newNo);
newNo = turnOffKUsingAnd(2, 1);
System.out.println(newNo);
}
// Logic: XOR with 1 right shifted to one less than 'k'. Problem with this
// logic is that if kth bit is already 0 then it will change it to 1, which
// is not the expected result.
private static int turnOffKMyWay(int n, int k) {
// TODO Auto-generated method stub
int onBit = 1;
int no = n ^ (onBit << (k - 1));
return no;
}
// Logic: First left shift 1 to k-1 bits then take bitwise NOT to it and
// lastly apply bitwise AND between it and number. Bitwise NOT will convert
// all bits to 1 except k-1 th bit.
private static int turnOffKUsingAnd(int n, int k) {
return n & ~(1 << (k - 1));
}
}
| [
"noreply@github.com"
] | hbtidotgkb.noreply@github.com |
75085e58a0be38a3fbe6c2d8845221cca41d0bec | f6b39d98d6095bea05195702cce5b9a018764176 | /local-project/src/test/java/JustTest.java | 4c6b433bf0f9e9a68bba920e99df4687ace20fec | [] | no_license | Mrliutaotao/local-project | 7a0e2748355317e1c86edeaa76b5d9713367f4ac | 667280433fe44eea1f84914116662ef2daa9e9e7 | refs/heads/master | 2021-01-13T05:54:47.088774 | 2018-05-07T01:39:39 | 2018-05-07T01:39:39 | 94,972,987 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,549 | java | import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
/**
*
* @author: liutaotao
* @date : 2017年8月2日下午4:24:58
*
*/
public class JustTest {
public static void main(String [] ar) throws ParseException {
List<Date> dateList = new ArrayList<Date>();
dateList.add(new Date());
testPlan testPlan = new testPlan();
testPlan.setItem(dateList);
String ad = JSONObject.toJSONString(testPlan);
System.out.println(ad);
JSONObject result = new JSONObject();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("operate_id", "daf");
result.put("plans", "12121");
System.out.println(result);
String aString = result.toJSONString();
String dadf = JSONObject.toJSONString(map);
System.out.println(dadf);
SimpleDateFormat formadt = new SimpleDateFormat("yyyy-MM-dd");
String daf = formadt.format(new Date());
System.out.println(daf);
int year = 201708/100;
int month = Integer.parseInt((201708 + "").substring(4, 6));
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date date = cal.getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String aDate = format.format(date);
Date lDate = format.parse(aDate);
System.out.println(date);
}
}
| [
"liutaotao@aixuedai.com"
] | liutaotao@aixuedai.com |
8d9221feab09fe51079202203eafdee0c68bc3da | 7ea86bbcee4ed2b05e91b50b561e1a95bddd3aaf | /app/src/main/java/com/r3dtech/life/data_loading/SerializableDataHelper.java | bb3dfa8e4e4bea85aa70c283a4fbb818b2258b0f | [] | no_license | maya-schles/LifeApp | f10e8058514edc9d2ae9c89dc7cad5383b19c96a | f74fd0217b30cf8630de6c4a993382ba1ff8d508 | refs/heads/master | 2021-04-09T16:14:27.816707 | 2018-05-02T20:45:09 | 2018-05-02T20:45:09 | 125,757,429 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,431 | java | package com.r3dtech.life.data_loading;
import android.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public interface SerializableDataHelper {
static String serialize(Serializable object) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bos);
os.writeObject(object);
//String res = new String(Base64.getEncoder().encode(bos.toByteArray()));
String res = Base64.encodeToString(bos.toByteArray(), Base64.DEFAULT);
os.close();
return res;
}
static Object deserialize(String data) throws IOException, ClassNotFoundException {
if (data.equals("")) {
return null;
}
byte[] bytes = data.getBytes();
//ByteArrayInputStream bis = new ByteArrayInputStream(Base64.getDecoder().decode(bytes));
ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(data, Base64.DEFAULT));
ObjectInputStream oInputStream = new ObjectInputStream(bis);
Object res = oInputStream.readObject();
oInputStream.close();
return res;
}
void write(Serializable object, String tag) throws IOException;
Object read(String tag) throws IOException;
}
| [
"maya.schlesinger@gmail.com"
] | maya.schlesinger@gmail.com |
b853767ad2c0ecb39e753763379a246fbf9734af | f3c0028d4138c69c4ce24b2fd01e4ca595a6af4d | /app/src/main/java/com/siweisoft/nurse/ui/base/bean/reqbean/BaseNurseReqBean.java | 5437c69ed002b62703bb028d6aa7c4fe24da82b5 | [] | no_license | canvaser/desktop | 83138fa37b36a02d4663d5e9cb136313f501a43e | 7652ece27d050d627c95fe0934734bf05db2cb0e | refs/heads/master | 2021-01-13T03:09:42.346997 | 2017-02-07T01:43:59 | 2017-02-07T01:43:59 | 77,433,645 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,384 | java | package com.siweisoft.nurse.ui.base.bean.reqbean;
import com.siweisoft.base.ui.bean.BaseBean;
import com.siweisoft.network.bean.req.BaseReqBean;
import com.siweisoft.network.bean.res.BaseResBean;
/**
* Created by ${viwmox} on 2016-11-16.
*/
public class BaseNurseReqBean extends BaseReqBean{
/**获取该指定病区的任务;可忽略,忽略时默认为当前用户所在的病区*/
private String rid;
private String begin;
private String end;
private String zyh;
private String patientid;
private String regionid;
public String getRegionid() {
return regionid;
}
public void setRegionid(String regionid) {
this.regionid = regionid;
}
public String getPatientid() {
return patientid;
}
public void setPatientid(String patientid) {
this.patientid = patientid;
}
public String getBegin() {
return begin;
}
public void setBegin(String begin) {
this.begin = begin;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
public String getZyh() {
return zyh;
}
public void setZyh(String zyh) {
this.zyh = zyh;
}
public String getRid() {
return rid;
}
public void setRid(String rid) {
this.rid = rid;
}
}
| [
"18721607438@163.com"
] | 18721607438@163.com |
bee8c36cfe919a2e865f6fa91d4b1be246c17d3e | e848c1caa613fa3a11824710a5a69c3841b42b98 | /src/main/java/org/stjs/javascript/dom/DOMImplementation.java | 119b83649ce6f59f4a81017a0f37db3553290a93 | [] | no_license | st-js/html-bridge | 4c21f862ede659fb583b2cecd513e4b74a57e6d4 | de6c40bcf3dd713c8c958850841b8050aa096a8c | refs/heads/master | 2020-05-21T03:08:35.880272 | 2017-01-12T10:09:16 | 2017-01-12T10:09:16 | 12,039,050 | 3 | 4 | null | 2017-01-12T10:09:17 | 2013-08-11T16:50:35 | Java | UTF-8 | Java | false | false | 258 | java | package org.stjs.javascript.dom;
import java.lang.Object;
import org.stjs.javascript.annotation.STJSBridge;
@STJSBridge
public interface DOMImplementation {
Document createDocument(String namespaceURI, String qualifiedNameStr, Object documentType);
}
| [
"anton@linevich.com"
] | anton@linevich.com |
ef430093c69700383bfaa699a6eb0a90e22e4cf5 | ff55e367f4b0952559284ebc18bb18df46230760 | /src/main/java/top/duanhong/steward/request/DictAddReq.java | d67f98efc49a965c872bd9859e32ee38122c223a | [] | no_license | duan-hong/steward | 120edee2fc961038ffaa9b07cbef195ff2f4f66d | d1de7cb1aefe28c9e720d07441bc907022434c85 | refs/heads/master | 2023-08-03T11:32:41.987053 | 2019-09-21T10:52:07 | 2019-09-21T10:52:07 | 208,597,013 | 0 | 1 | null | 2023-07-22T16:14:47 | 2019-09-15T13:18:14 | Java | UTF-8 | Java | false | false | 375 | java | package top.duanhong.steward.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author duanhong
* @description 字典新增
* @date 2019/8/16
*/
@Data
public class DictAddReq {
@NotBlank(message = "字典的键不能拿为空")
private String key;
@NotBlank(message = "字典的值不能为空")
private String value;
}
| [
"zhang13402930485@163.com"
] | zhang13402930485@163.com |
9941ad6727faf7cf96f91815ba56284e3491a9ef | d275e889e21ef60d65e217d23b4366dfb0ea54da | /src/fdt/fuzzy/TrapezoidalFuzzySet.java | 0a47eb3e409880ff315a3a114ceed0b8d9248ee4 | [
"MIT"
] | permissive | mxrsp/FDTKit | 48b38d221c064a98240106f67c704ad89e1def14 | 355f4c91afc072bd13d69ae5817bd14b73affd61 | refs/heads/master | 2022-12-11T12:24:59.375689 | 2020-09-16T14:12:34 | 2020-09-16T14:12:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,826 | java |
package fdt.fuzzy;
import fdt.utils.Tuple;
/**
*
* @author Mohammed Jabreel
*
*/
public class TrapezoidalFuzzySet extends PiecewiseLinearFunction {
/**
*
* @param size
*/
public TrapezoidalFuzzySet(int size) {
this.points = new Tuple[size];
}
/**
*
* @param m1
* @param m2
* @param m3
* @param m4
* @param max
* @param min
*/
public TrapezoidalFuzzySet(double m1, double m2, double m3, double m4, double max, double min) {
this(4);
this.points[0] = new Tuple<>(m1, min);
this.points[1] = new Tuple<>(m2, max);
this.points[2] = new Tuple<>(m3, max);
this.points[3] = new Tuple<>(m4, min);
}
/**
*
* @param m1
* @param m2
* @param m3
* @param m4
*/
public TrapezoidalFuzzySet(double m1, double m2, double m3, double m4) {
this(m1, m2, m3, m4, 1.0, 0.0);
}
/**
*
* @param m1
* @param m2
* @param m3
* @param max
* @param min
*/
public TrapezoidalFuzzySet(double m1, double m2, double m3, double max, double min) {
this(3);
this.points[0] = new Tuple<>(m1, min);
this.points[1] = new Tuple<>(m2, max);
this.points[2] = new Tuple<>(m3, min);
}
/**
*
* @param m1
* @param m2
* @param m3
*/
public TrapezoidalFuzzySet(double m1, double m2, double m3 ) {
this(m1, m2, m3, 1.0, 0.0);
}
/**
*
* @param m1
* @param m2
* @param max
* @param min
* @param edge
*/
public TrapezoidalFuzzySet(double m1, double m2, double max, double min, EdgeType edge) {
this(2);
if(edge == EdgeType.Left) {
this.points[0] = new Tuple<>(m1, min );
this.points[1] = new Tuple<>( m2, max );
}
else {
this.points[0] = new Tuple<>( m1, max );
this.points[1] = new Tuple<>( m2, min );
}
}
/**
*
* @param m1
* @param m2
* @param edge
*/
public TrapezoidalFuzzySet(double m1, double m2, EdgeType edge) {
this(m1, m2, 1.0, 0.0, edge);
}
/**
*
* @return
*/
public double getA() {
return this.points[0].getFirst();
}
/**
*
* @return
*/
public double getB() {
return this.points[1].getFirst();
}
/**
*
* @return
*/
public double getC() {
return this.points[2].getFirst();
}
/**
*
* @return
*/
public double getD() {
return this.points[3].getFirst();
}
/**
*
* @return
*/
@Override
public String toString() {
return "Trapezodial Function";
}
}
| [
"mhjabreel@gmail.com"
] | mhjabreel@gmail.com |
37b64d84b23cf954b9cbc753f2af2f5516d7be02 | b12949e16108cd8a195c993bc1046384450c8048 | /src/test/java/fm/pattern/valex/PatternAssertions.java | 5e27a9704672fd7ce57106ff853c21b9cf367593 | [
"Apache-2.0"
] | permissive | PatternFM/valex | a3080080d6eca9ad9a5b4ba241fbf237c02d7a8b | 9ee925b7f24264920766728ab5efee6485e371a6 | refs/heads/master | 2021-06-22T20:03:40.443271 | 2017-07-17T11:21:01 | 2017-07-17T11:21:01 | 82,427,271 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 369 | java | package fm.pattern.valex;
import org.assertj.core.api.Assertions;
public class PatternAssertions extends Assertions {
public static ResultAssertions assertThat(Result<?> result) {
return new ResultAssertions(result);
}
public static UtilityClassAssertions assertClass(Class<?> clazz) {
return new UtilityClassAssertions(clazz);
}
}
| [
"brandon.john.grenier@gmail.com"
] | brandon.john.grenier@gmail.com |
7bcfe29847f77b6b6cb8de8c46d217479d831075 | 0697003961b21e15962208b174011ad059295e65 | /app/src/main/java/lu/btsi/bragi/ros/rosandroid/LanguageObserver.java | 926c6f2e0bfdc43efbc1ca57a0de1912313ac368 | [] | no_license | gillesbraun/RestaurantOrderingSystem-Android | b03e7c0ed8c4579a4030897e6c3f5c982b902e68 | 5fb30d81e5070ea174a3695869105645d2e1dd95 | refs/heads/master | 2022-06-07T20:22:39.362695 | 2017-03-28T09:28:22 | 2017-03-28T09:28:22 | 133,950,625 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 155 | java | package lu.btsi.bragi.ros.rosandroid;
/**
* Created by gillesbraun on 27/03/2017.
*/
public interface LanguageObserver {
void languageChanged();
}
| [
"braun.gillo@gmail.com"
] | braun.gillo@gmail.com |
72b600e423a478b891a7ddbcd87771ba278c3e7c | f22340f0d277081bf1ee79636aa8845fb42a8024 | /src/main/java/puzzle/parsers/CompareExpression.java | 3d0ca8a169ea55cc63b9cb3c9075fcb6a0600587 | [] | no_license | saka1029/Puzzle | f0cf6e611fcc46580fcfe03325dee76f6b440c9c | edf8810343190be530fb77f36c1414e8266e8a78 | refs/heads/master | 2023-04-03T10:00:48.988223 | 2023-03-19T21:41:46 | 2023-03-19T21:41:46 | 208,369,149 | 0 | 0 | null | 2022-09-01T23:52:07 | 2019-09-14T00:50:11 | Java | UTF-8 | Java | false | false | 2,919 | java | package puzzle.parsers;
public class CompareExpression {
/**
* expression = or
* or = and { '||' and }
* and = factor { '&&' factor }
* factor = paren | comp
* paren = '(' expression ')'
* comp = number op number
* op = '==' | '!=' | '<' | '<= | '>' | '>='
*/
static boolean eval(String expression) {
return new Object() {
int index = 0;
int ch = get();
int get() {
return ch = index < expression.length() ? expression.charAt(index++) : -1;
}
void spaces() {
while (Character.isWhitespace(ch))
get();
}
boolean eat(String word) {
spaces();
if (ch != word.charAt(0) || !expression.startsWith(word.substring(1), index))
return false;
index += word.length() - 1;
get();
return true;
}
int number() {
spaces();
if (ch != '-' && !Character.isDigit(ch))
throw new RuntimeException(
"number expected but '" + ((char)ch) + "'");
StringBuilder sb = new StringBuilder();
do {
sb.append((char)ch);
get();
} while (Character.isDigit(ch));
return Integer.parseInt(sb.toString());
}
boolean paren() {
boolean result = or();
if (!eat(")")) throw new RuntimeException("')' expected");
return result;
}
boolean comp() {
if (eat("(")) return paren();
int term = number();
if (eat("==")) return term == number();
else if (eat("!=")) return term != number();
else if (eat("<=")) return term <= number();
else if (eat("<")) return term < number();
else if (eat(">=")) return term >= number();
else if (eat(">")) return term > number();
else throw new RuntimeException();
}
boolean and() {
boolean result = comp();
while (eat("&&"))
result &= comp();
return result;
}
boolean or() {
boolean result = and();
while (eat("||"))
result |= and();
return result;
}
boolean parse() {
boolean result = or();
if (ch != -1)
throw new RuntimeException(
"extra char '" + expression.substring(index - 1) + "'");
return result;
}
}.parse();
}
}
| [
"saka1029@gmail.com"
] | saka1029@gmail.com |
c3a8ea0b1f02ec90bca4b644115b99f051b63bb8 | 1f45dafb232759e3028b7d524cf708dc2a31d1b3 | /programs/dld/MaheshFrame.java | 600d24e0bf56a3887cfba635d638916ff58557cf | [] | no_license | gcsr/btech-practice-codes | 06eacfeb6a7074b2244383a6110f77abdfc052b3 | f95a79f23484740d82eebe24763996beddd1ace7 | refs/heads/master | 2022-11-19T17:37:39.220405 | 2020-07-23T18:17:58 | 2020-07-23T18:17:58 | 263,967,369 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 623 | java | import javax.swing.JFrame;
import javax.swing.JList;
import java.awt.BorderLayout;
import javax.swing.JButton;
public class MaheshFrame extends JFrame{
JList list;
/**
* @param args
*/
MaheshFrame()
{
String[] selection={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18",};
list =new JList(selection);
list.setVisibleRowCount(5);
list.setSelectedIndex(4);
setLayout(new BorderLayout());
add(list,BorderLayout.NORTH);
setSize(500,500);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new MaheshFrame();
}
}
| [
"gc.sekhar002@gmail.com"
] | gc.sekhar002@gmail.com |
c44a267589b951676e2b57ab4c00e795a7aedb07 | c9f54d4eb807699924d74bef227f61beddd68c2d | /module-webrtc/src/main/java/com/anber/webrtc/ui/viewmodel/WorkViewModel.java | 852a7b03e341800f4364f6814d36d866e569fe62 | [] | no_license | anber1121/MultimediaExample | f4c242d9033f35036732a2343deee78578cb09ba | 0a14c9a849cdec6b818539ec92e4c56f13db4286 | refs/heads/master | 2022-11-10T06:38:10.610283 | 2020-06-29T22:49:24 | 2020-06-29T22:49:24 | 275,940,728 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,030 | java | package com.anber.webrtc.ui.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableList;
import com.goldze.base.base.BaseViewModel;
import com.anber.webrtc.BR;
import com.anber.webrtc.R;
import me.tatarka.bindingcollectionadapter2.ItemBinding;
/**
* Created by goldze on 2018/6/21.
*/
public class WorkViewModel extends BaseViewModel {
public WorkViewModel(@NonNull Application application) {
super(application);
}
@Override
public void onCreate() {
super.onCreate();
for (int i = 0; i < 10; i++) {
observableList.add(new WorkItemViewModel(this, "条目" + i));
}
}
//给RecyclerView添加ObservableList
public ObservableList<WorkItemViewModel> observableList = new ObservableArrayList<>();
//给RecyclerView添加ItemBinding
public ItemBinding<WorkItemViewModel> itemBinding = ItemBinding.of(BR.viewModel, R.layout.grid_work);
}
| [
"xubiao9@huawei.com"
] | xubiao9@huawei.com |
91eba780e24d7e1ca83daa6b3eb90bbf38fbc2dc | e2f01bd3aa3dae6ead2c1626e9aba91efab2e182 | /iws-ws-client/src/test/java/net/iaeste/iws/ws/client/mappers/CommonMapperTest.java | e1dc3309bdf0500cfd53138b65208100ae8eabe3 | [
"Apache-2.0"
] | permissive | iaeste-lc-aachen/iws | df3c751ad065daef4ebf0919ed8ecbaefe423355 | 1b86f9477b8b4e2683aeafd6199de24c6b922742 | refs/heads/master | 2021-01-22T21:12:51.157769 | 2016-09-30T07:01:07 | 2016-09-30T07:01:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,101 | java | /*
* Licensed to IAESTE A.s.b.l. (IAESTE) under one or more contributor
* license agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership. The Authors
* (See the AUTHORS file distributed with this work) 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 net.iaeste.iws.ws.client.mappers;
import static net.iaeste.iws.ws.client.mappers.CommonMapper.map;
import static net.iaeste.iws.ws.client.mappers.TestUtils.prepareAddress;
import static net.iaeste.iws.ws.client.mappers.TestUtils.prepareCountry;
import static net.iaeste.iws.ws.client.mappers.TestUtils.prepareGroup;
import static net.iaeste.iws.ws.client.mappers.TestUtils.preparePerson;
import static net.iaeste.iws.ws.client.mappers.TestUtils.prepareRole;
import static net.iaeste.iws.ws.client.mappers.TestUtils.prepareUser;
import static net.iaeste.iws.ws.client.mappers.TestUtils.prepareUserGroup;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import net.iaeste.iws.api.constants.IWSError;
import net.iaeste.iws.api.dtos.Address;
import net.iaeste.iws.api.dtos.AuthenticationToken;
import net.iaeste.iws.api.dtos.Country;
import net.iaeste.iws.api.dtos.Group;
import net.iaeste.iws.api.dtos.Person;
import net.iaeste.iws.api.dtos.Role;
import net.iaeste.iws.api.dtos.User;
import net.iaeste.iws.api.dtos.UserGroup;
import net.iaeste.iws.ws.IwsError;
import org.junit.Test;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.UUID;
/**
* @author Kim Jensen / last $Author:$
* @version $Revision:$ / $Date:$
* @since IWS 1.2
*/
public final class CommonMapperTest {
/**
* <p>Private methods should never be tested, as they are part of an
* internal workflow. Classes should always be tested via their contract,
* i.e. public methods.</p>
*
* <p>However, for Utility Classes, with a Private Constructor, the contract
* disallows instantiation, so the constructor is thus not testable via
* normal means. This little Test method will just do that.</p>
*/
@Test
public void testPrivateConstructor() {
try {
final Constructor<CommonMapper> constructor = CommonMapper.class.getDeclaredConstructor();
constructor.setAccessible(true);
final CommonMapper mapper = constructor.newInstance();
assertThat(mapper, is(not(nullValue())));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException e) {
fail("Could not invoke Private Constructor: " + e.getMessage());
}
}
/**
* <p>Similar to the test above, but for the parent Class, which handles
* mapping of enumerated values.</p>
*/
@Test
public void testPrivateEnumConstructor() {
try {
final Constructor<EnumMapper> constructor = EnumMapper.class.getDeclaredConstructor();
constructor.setAccessible(true);
final EnumMapper mapper = constructor.newInstance();
assertThat(mapper, is(not(nullValue())));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException e) {
fail("Could not invoke Private Constructor: " + e.getMessage());
}
}
@Test
public void testNullAuthenticationToken() {
final AuthenticationToken token = null;
final AuthenticationToken mapped = map(map(token));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getToken(), is(nullValue()));
assertThat(mapped.getGroupId(), is(nullValue()));
}
@Test
public void testAuthenticationToken() {
final String key = "1345678901345678901345678901345678901345678901345678901345678901";
final String groupId = UUID.randomUUID().toString();
final AuthenticationToken token = new AuthenticationToken();
token.setToken(key);
token.setGroupId(groupId);
final AuthenticationToken mapped = map(map(token));
assertThat(mapped.getToken(), is(key));
assertThat(mapped.getGroupId(), is(groupId));
}
@Test
public void testNullError() {
final IwsError api = null;
final IWSError mapped = map(api);
assertThat(mapped, is(nullValue()));
}
@Test
public void testNullCountry() {
final Country country = null;
final Country mapped = map(map(country));
assertThat(mapped, is(nullValue()));
}
@Test
public void testCountry() {
final Country country = prepareCountry();
final Country mapped = map(map(country));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getCountryCode(), is(country.getCountryCode()));
assertThat(mapped.getCountryName(), is(country.getCountryName()));
assertThat(mapped.getCountryNameFull(), is(country.getCountryNameFull()));
assertThat(mapped.getCountryNameNative(), is(country.getCountryNameNative()));
assertThat(mapped.getNationality(), is(country.getNationality()));
assertThat(mapped.getPhonecode(), is(country.getPhonecode()));
assertThat(mapped.getCurrency(), is(country.getCurrency()));
assertThat(mapped.getLanguages(), is(country.getLanguages()));
assertThat(mapped.getMembership(), is(country.getMembership()));
assertThat(mapped.getMemberSince(), is(country.getMemberSince()));
assertThat(mapped, is(country));
}
@Test
public void testNullAddress() {
final Address address = null;
final Address mapped = map(map(address));
assertThat(mapped, is(nullValue()));
}
@Test
public void testAddress() {
final Address address = prepareAddress();
final Address mapped = map(map(address));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getStreet1(), is(address.getStreet1()));
assertThat(mapped.getStreet2(), is(address.getStreet2()));
assertThat(mapped.getPostalCode(), is(address.getPostalCode()));
assertThat(mapped.getCity(), is(address.getCity()));
assertThat(mapped.getState(), is(address.getState()));
assertThat(mapped.getPobox(), is(address.getPobox()));
assertThat(mapped.getCountry(), is(address.getCountry()));
}
@Test
public void testNullPerson() {
final Person person = null;
final Person mapped = map(map(person));
assertThat(mapped, is(nullValue()));
}
@Test
public void testPerson() {
final Person person = preparePerson();
final Person mapped = map(map(person));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getNationality(), is(person.getNationality()));
assertThat(mapped.getAddress(), is(person.getAddress()));
assertThat(mapped.getAlternateEmail(), is(person.getAlternateEmail()));
assertThat(mapped.getPhone(), is(person.getPhone()));
assertThat(mapped.getMobile(), is(person.getMobile()));
assertThat(mapped.getFax(), is(person.getFax()));
assertThat(mapped.getBirthday(), is(person.getBirthday()));
assertThat(mapped.getGender(), is(person.getGender()));
assertThat(mapped.getUnderstoodPrivacySettings(), is(person.getUnderstoodPrivacySettings()));
assertThat(mapped.getAcceptNewsletters(), is(person.getAcceptNewsletters()));
}
@Test
public void testNullUser() {
final User user = null;
final User mapped = map(map(user));
assertThat(mapped, is(nullValue()));
}
@Test
public void testUser() {
final User user = prepareUser();
final User mapped = map(map(user));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getUserId(), is(user.getUserId()));
assertThat(mapped.getUsername(), is(user.getUsername()));
assertThat(mapped.getAlias(), is(user.getAlias()));
assertThat(mapped.getFirstname(), is(user.getFirstname()));
assertThat(mapped.getLastname(), is(user.getLastname()));
assertThat(mapped.getPerson(), is(user.getPerson()));
assertThat(mapped.getStatus(), is(user.getStatus()));
assertThat(mapped.getType(), is(user.getType()));
assertThat(mapped.getPrivacy(), is(user.getPrivacy()));
assertThat(mapped.getNotifications(), is(user.getNotifications()));
}
@Test
public void testNullGroup() {
final Group group = null;
final Group mapped = map(map(group));
assertThat(mapped, is(nullValue()));
}
@Test
public void testGroup() {
final Group group = prepareGroup();
final Group mapped = map(map(group));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getGroupId(), is(group.getGroupId()));
assertThat(mapped.getParentId(), is(group.getParentId()));
assertThat(mapped.getGroupName(), is(group.getGroupName()));
assertThat(mapped.getFullName(), is(group.getFullName()));
assertThat(mapped.getListName(), is(group.getListName()));
assertThat(mapped.getPrivateList(), is(group.getPrivateList()));
assertThat(mapped.getPrivateListReplyTo(), is(group.getPrivateListReplyTo()));
assertThat(mapped.getPublicList(), is(group.getPublicList()));
assertThat(mapped.getPublicListReplyTo(), is(group.getPublicListReplyTo()));
assertThat(mapped.getGroupType(), is(group.getGroupType()));
assertThat(mapped.getDescription(), is(group.getDescription()));
assertThat(mapped.getMonitoringLevel(), is(group.getMonitoringLevel()));
assertThat(mapped.getCountry(), is(group.getCountry()));
}
@Test
public void testNullRole() {
final Role role = null;
final Role mapped = map(map(role));
assertThat(mapped, is(nullValue()));
}
@Test
public void testRole() {
final Role role = prepareRole();
final Role mapped = map(map(role));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getRoleId(), is(role.getRoleId()));
assertThat(mapped.getRoleName(), is(role.getRoleName()));
assertThat(mapped.getPermissions(), is(role.getPermissions()));
}
@Test
public void testNullUserGroup() {
final UserGroup userGroup = null;
final UserGroup mapped = map(map(userGroup));
assertThat(mapped, is(nullValue()));
}
@Test
public void testUserGroup() {
final UserGroup userGroup = prepareUserGroup();
final UserGroup mapped = map(map(userGroup));
assertThat(mapped, is(not(nullValue())));
assertThat(mapped.getUserGroupId(), is(userGroup.getUserGroupId()));
assertThat(mapped.getUser(), is(userGroup.getUser()));
assertThat(mapped.getGroup(), is(userGroup.getGroup()));
assertThat(mapped.getRole(), is(userGroup.getRole()));
assertThat(mapped.getTitle(), is(userGroup.getTitle()));
assertThat(mapped.isOnPublicList(), is(userGroup.isOnPublicList()));
assertThat(mapped.isOnPrivateList(), is(userGroup.isOnPrivateList()));
assertThat(mapped.mayWriteToPrivateList(), is(userGroup.mayWriteToPrivateList()));
assertThat(mapped.getMemberSince(), is(userGroup.getMemberSince()));
}
}
| [
"kim@dawn.dk"
] | kim@dawn.dk |
78bce77694868c4babf88b1020f9bff6431ad607 | f66d7ca484421ac287f745a6b81a3d653a06844a | /app/src/main/java/com/example/demo/SplashScreen.java | c40b9ab9c546ca720a5f6132ebeb39385734dbd2 | [] | no_license | TridentDAO/CricketPredictionAndTipsAndroid | c19b16753c30ee7661aa15d8734eca69f4151354 | 7807d625c2699235924f53680ce3bc44b89b3153 | refs/heads/master | 2023-05-29T21:22:01.449371 | 2021-06-15T09:10:37 | 2021-06-15T09:10:37 | 377,105,234 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 416 | java | package com.example.demo;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class SplashScreen extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActivity(new Intent(this,MainActivity.class));
}
}
| [
"dishantaarak2696@gmail.com"
] | dishantaarak2696@gmail.com |
9210fd67f5dd05bfd3c3458c3f3ddff012b53290 | 1655c32877cb1a66f6804ea17fcb1c279d0fef72 | /platforms/java/api/gen/src/dust/gen/DustGenCounter.java | e24a9164cf15f9f7e70d7fadd4563133fb6a4998 | [
"Apache-2.0"
] | permissive | MondoAurora/ARK | 0c52271f12e0eca4d56cb388870f335301a5ecf6 | 88a3f5ea27f1970f766714d1303c11929888c176 | refs/heads/master | 2023-02-03T09:04:39.603843 | 2020-12-14T16:16:45 | 2020-12-14T16:16:45 | 261,684,206 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,114 | java | package dust.gen;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
public class DustGenCounter implements Iterable<Map.Entry<Object, Long>>{
Map<Object, Long> counts;
public DustGenCounter() {
this(false);
}
public DustGenCounter(boolean sorted) {
counts = sorted ? new TreeMap<>() : new HashMap<>();
}
public void reset() {
counts.clear();
}
public void add(Object ob) {
Long l = counts.get(ob);
counts.put(ob, (null == l) ? 1 : l+1);
}
@Override
public String toString() {
StringBuilder sb = null;
for ( Map.Entry<Object, Long> e : this ) {
sb = DustGenUtils.sbAppend(sb, ", ", false, e.getKey());
DustGenUtils.sbAppend(sb, "", false, ": ", e.getValue());
}
return DustGenUtils.toStringSafe(sb);
}
@Override
public Iterator<Entry<Object, Long>> iterator() {
return counts.entrySet().iterator();
}
}
| [
"lorand.kedves@gmail.com"
] | lorand.kedves@gmail.com |
151d18de064de9850e590bf325a4559ee2ec429d | 180e78725121de49801e34de358c32cf7148b0a2 | /dataset/protocol1/kylin/learning/2770/ImmutableBitSet.java | 1524adcd79bcb5a54e632adbbfe0c6f148f13f47 | [] | no_license | ASSERT-KTH/synthetic-checkstyle-error-dataset | 40e8d1e0a7ebe7f7711def96a390891a6922f7bd | 40c057e1669584bfc6fecf789b5b2854660222f3 | refs/heads/master | 2023-03-18T12:50:55.410343 | 2019-01-25T09:54:39 | 2019-01-25T09:54:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,445 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.kylin.common.util;
import java.nio.ByteBuffer;
import java.util.BitSet;
import java.util.Iterator;
public class ImmutableBitSet implements Iterable<Integer> {
public static final ImmutableBitSet EMPTY = new ImmutableBitSet(new BitSet());
public static ImmutableBitSet valueOf(int... values) { BitSet set = new BitSet();
for (int i : values)
set.set(i);
return new ImmutableBitSet(set);
}
// ============================================================================
final private BitSet set;
final private int[] arr;
public ImmutableBitSet(int index) {
this(newBitSet(index));
}
public ImmutableBitSet(BitSet set) {
this.set = (BitSet) set.clone();
this.arr = new int[set.cardinality()];
int j = 0;
for (int i = set.nextSetBit(0); i >= 0; i = set.nextSetBit(i + 1)) {
arr[j++] = i;
}
}
private static BitSet newBitSet(int index) {
BitSet set = new BitSet(index);
set.set(index);
return set;
}
public ImmutableBitSet(int indexFrom, int indexTo) {
this(newBitSet(indexFrom, indexTo));
}
private static BitSet newBitSet(int indexFrom, int indexTo) {
BitSet set = new BitSet(indexTo);
set.set(indexFrom, indexTo);
return set;
}
/** return number of true bits */
public int trueBitCount() {
return arr.length;
}
/** return the i-th true bit */
public int trueBitAt(int i) {
return arr[i];
}
/** return the bit's index among true bits */
public int trueBitIndexOf(int bitIndex) {
for (int i = 0; i < arr.length; i++) {
if (arr[i] == bitIndex)
return i;
}
return -1;
}
public BitSet mutable() {
return (BitSet) set.clone();
}
public ImmutableBitSet set(int bitIndex) {
return set(bitIndex, true);
}
public ImmutableBitSet set(int bitIndex, boolean value) {
if (set.get(bitIndex) == value) {
return this;
} else {
BitSet mutable = mutable();
mutable.set(bitIndex, value);
return new ImmutableBitSet(mutable);
}
}
public ImmutableBitSet or(ImmutableBitSet another) {
BitSet mutable = mutable();
mutable.or(another.set);
return new ImmutableBitSet(mutable);
}
public ImmutableBitSet andNot(ImmutableBitSet another) {
BitSet mutable = mutable();
mutable.andNot(another.set);
return new ImmutableBitSet(mutable);
}
@Override
public int hashCode() {
return set.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ImmutableBitSet other = (ImmutableBitSet) obj;
return this.set.equals(other.set);
}
@Override
public String toString() {
return set.toString();
}
// ============================================================================
public boolean get(int bitIndex) {
return set.get(bitIndex);
}
public int cardinality() {
return set.cardinality();
}
public boolean intersects(ImmutableBitSet another) {
return set.intersects(another.set);
}
public boolean isEmpty() {
return set.isEmpty();
}
public static final BytesSerializer<ImmutableBitSet> serializer = new BytesSerializer<ImmutableBitSet>() {
@Override
public void serialize(ImmutableBitSet value, ByteBuffer out) {
BytesUtil.writeByteArray(value.set.toByteArray(), out);
}
@Override
public ImmutableBitSet deserialize(ByteBuffer in) {
BitSet bitSet = BitSet.valueOf(BytesUtil.readByteArray(in));
return new ImmutableBitSet(bitSet);
}
};
/**
* Iterate over the positions of true value.
* @return the iterator
*/
@Override
public Iterator<Integer> iterator() {
return new Iterator<Integer>() {
int index = 0;
@Override
public boolean hasNext() {
return index < arr.length;
}
@Override
public Integer next() {
return arr[index++];
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
}
| [
"bloriot97@gmail.com"
] | bloriot97@gmail.com |
c0e45c29da5d559b74c2c37515a81d6b6cf4347f | fe06f97c2cf33a8b4acb7cb324b79a6cb6bb9dac | /java/dao/impl/CLMS_AP/InUps1DAOImpl.java | aa3873d920d68ed941391d0e56a1faf0c7e39a9d | [] | no_license | HeimlichLin/TableSchema | 3f67dae0b5b169ee3a1b34837ea9a2d34265f175 | 64b66a2968c3a169b75d70d9e5cf75fa3bb65354 | refs/heads/master | 2023-02-11T09:42:47.210289 | 2023-02-01T02:58:44 | 2023-02-01T02:58:44 | 196,526,843 | 0 | 0 | null | 2022-06-29T18:53:55 | 2019-07-12T07:03:58 | Java | UTF-8 | Java | false | false | 3,669 | java | package com.doc.common.dao.impl;
public class InUps1DAOImpl extends GeneralDAOImpl<InUps1Po> implements InUps1DAO {
public static final InUps1DAOImpl INSTANCE = new InUps1DAOImpl();
public static final String TABLENAME = "IN_UPS1";
public InUps1DAOImpl() {
super(TABLENAME);
}
protected static final MapConverter<InUps1Po> CONVERTER = new MapConverter<InUps1Po>() {
@Override
public InUps1Po convert(final DataObject dataObject) {
final InUps1Po inUps1Po = new InUps1Po();
inUps1Po.setBondno(dataObject.getString(InUps1Po.COLUMNS.BONDNO.name()));
inUps1Po.setGdstype(dataObject.getString(InUps1Po.COLUMNS.GDSTYPE.name()));
inUps1Po.setDecltype(dataObject.getString(InUps1Po.COLUMNS.DECLTYPE.name()));
inUps1Po.setPrdtno(dataObject.getString(InUps1Po.COLUMNS.PRDTNO.name()));
inUps1Po.setDeclno(dataObject.getString(InUps1Po.COLUMNS.DECLNO.name()));
inUps1Po.setItemno(BigDecimalUtils.formObj(dataObject.getValue(InUps1Po.COLUMNS.ITEMNO.name())));
inUps1Po.setStockno(dataObject.getString(InUps1Po.COLUMNS.STOCKNO.name()));
inUps1Po.setIndate(dataObject.getString(InUps1Po.COLUMNS.INDATE.name()));
inUps1Po.setRinqty(BigDecimalUtils.formObj(dataObject.getValue(InUps1Po.COLUMNS.RINQTY.name())));
inUps1Po.setInunit(dataObject.getString(InUps1Po.COLUMNS.INUNIT.name()));
inUps1Po.setInpost(dataObject.getString(InUps1Po.COLUMNS.INPOST.name()));
inUps1Po.setBalance(BigDecimalUtils.formObj(dataObject.getValue(InUps1Po.COLUMNS.BALANCE.name())));
inUps1Po.setIsstock(dataObject.getString(InUps1Po.COLUMNS.ISSTOCK.name()));
inUps1Po.setRmk(dataObject.getString(InUps1Po.COLUMNS.RMK.name()));
inUps1Po.setInstatus(dataObject.getString(InUps1Po.COLUMNS.INSTATUS.name()));
inUps1Po.setControlno(dataObject.getString(InUps1Po.COLUMNS.CONTROLNO.name()));
inUps1Po.setUpdtime(dataObject.getString(InUps1Po.COLUMNS.UPDTIME.name()));
return inUps1Po;
}
@Override
public DataObject toDataObject(final InUps1Po inUps1Po) {
final DataObject dataObject = new DataObject();
dataObject.setValue(InUps1Po.COLUMNS.BONDNO.name(), inUps1Po.getBondno());
dataObject.setValue(InUps1Po.COLUMNS.GDSTYPE.name(), inUps1Po.getGdstype());
dataObject.setValue(InUps1Po.COLUMNS.DECLTYPE.name(), inUps1Po.getDecltype());
dataObject.setValue(InUps1Po.COLUMNS.PRDTNO.name(), inUps1Po.getPrdtno());
dataObject.setValue(InUps1Po.COLUMNS.DECLNO.name(), inUps1Po.getDeclno());
dataObject.setValue(InUps1Po.COLUMNS.ITEMNO.name(), inUps1Po.getItemno());
dataObject.setValue(InUps1Po.COLUMNS.STOCKNO.name(), inUps1Po.getStockno());
dataObject.setValue(InUps1Po.COLUMNS.INDATE.name(), inUps1Po.getIndate());
dataObject.setValue(InUps1Po.COLUMNS.RINQTY.name(), inUps1Po.getRinqty());
dataObject.setValue(InUps1Po.COLUMNS.INUNIT.name(), inUps1Po.getInunit());
dataObject.setValue(InUps1Po.COLUMNS.INPOST.name(), inUps1Po.getInpost());
dataObject.setValue(InUps1Po.COLUMNS.BALANCE.name(), inUps1Po.getBalance());
dataObject.setValue(InUps1Po.COLUMNS.ISSTOCK.name(), inUps1Po.getIsstock());
dataObject.setValue(InUps1Po.COLUMNS.RMK.name(), inUps1Po.getRmk());
dataObject.setValue(InUps1Po.COLUMNS.INSTATUS.name(), inUps1Po.getInstatus());
dataObject.setValue(InUps1Po.COLUMNS.CONTROLNO.name(), inUps1Po.getControlno());
dataObject.setValue(InUps1Po.COLUMNS.UPDTIME.name(), inUps1Po.getUpdtime());
return dataObject;
}
};
public MapConverter<InUps1Po> getConverter() {
return CONVERTER;
}
@Override
public SqlWhere getPkSqlWhere(InUps1Po po) {
throw new ApBusinessException("無pk不支援");
}
}
| [
"jerry.l@acer.com"
] | jerry.l@acer.com |
04e7c6bfe9a0e72cfbb894b31f2e2936eb04d282 | 68ff94ffe8fcb22d188a7168544b30ae6f56e6e5 | /BooksSystem6/src/main/java/com/kgc/entity/BookInfoExample.java | 54d7ad0fda6f377837c6c594f57d9e64c608f9d1 | [
"Apache-2.0"
] | permissive | mys031103/Github-0927HomeWork | fcfa2ee5b9e3215ffe6d26bd1416a2e5da66536a | 639a473dd47455ab9e520b26faceec7944114076 | refs/heads/master | 2022-12-22T17:56:29.906369 | 2020-09-28T09:03:28 | 2020-09-28T09:03:28 | 299,016,021 | 0 | 0 | Apache-2.0 | 2020-09-28T09:03:29 | 2020-09-27T11:22:01 | Java | UTF-8 | Java | false | false | 31,848 | java | package com.kgc.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
public class BookInfoExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public BookInfoExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
protected void addCriterionForJDBCDate(String condition, Date value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
addCriterion(condition, new java.sql.Date(value.getTime()), property);
}
protected void addCriterionForJDBCDate(String condition, List<Date> values, String property) {
if (values == null || values.size() == 0) {
throw new RuntimeException("Value list for " + property + " cannot be null or empty");
}
List<java.sql.Date> dateList = new ArrayList<java.sql.Date>();
Iterator<Date> iter = values.iterator();
while (iter.hasNext()) {
dateList.add(new java.sql.Date(iter.next().getTime()));
}
addCriterion(condition, dateList, property);
}
protected void addCriterionForJDBCDate(String condition, Date value1, Date value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
addCriterion(condition, new java.sql.Date(value1.getTime()), new java.sql.Date(value2.getTime()), property);
}
public Criteria andBookIdIsNull() {
addCriterion("book_id is null");
return (Criteria) this;
}
public Criteria andBookIdIsNotNull() {
addCriterion("book_id is not null");
return (Criteria) this;
}
public Criteria andBookIdEqualTo(Integer value) {
addCriterion("book_id =", value, "bookId");
return (Criteria) this;
}
public Criteria andBookIdNotEqualTo(Integer value) {
addCriterion("book_id <>", value, "bookId");
return (Criteria) this;
}
public Criteria andBookIdGreaterThan(Integer value) {
addCriterion("book_id >", value, "bookId");
return (Criteria) this;
}
public Criteria andBookIdGreaterThanOrEqualTo(Integer value) {
addCriterion("book_id >=", value, "bookId");
return (Criteria) this;
}
public Criteria andBookIdLessThan(Integer value) {
addCriterion("book_id <", value, "bookId");
return (Criteria) this;
}
public Criteria andBookIdLessThanOrEqualTo(Integer value) {
addCriterion("book_id <=", value, "bookId");
return (Criteria) this;
}
public Criteria andBookIdIn(List<Integer> values) {
addCriterion("book_id in", values, "bookId");
return (Criteria) this;
}
public Criteria andBookIdNotIn(List<Integer> values) {
addCriterion("book_id not in", values, "bookId");
return (Criteria) this;
}
public Criteria andBookIdBetween(Integer value1, Integer value2) {
addCriterion("book_id between", value1, value2, "bookId");
return (Criteria) this;
}
public Criteria andBookIdNotBetween(Integer value1, Integer value2) {
addCriterion("book_id not between", value1, value2, "bookId");
return (Criteria) this;
}
public Criteria andBookCodeIsNull() {
addCriterion("book_code is null");
return (Criteria) this;
}
public Criteria andBookCodeIsNotNull() {
addCriterion("book_code is not null");
return (Criteria) this;
}
public Criteria andBookCodeEqualTo(String value) {
addCriterion("book_code =", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeNotEqualTo(String value) {
addCriterion("book_code <>", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeGreaterThan(String value) {
addCriterion("book_code >", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeGreaterThanOrEqualTo(String value) {
addCriterion("book_code >=", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeLessThan(String value) {
addCriterion("book_code <", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeLessThanOrEqualTo(String value) {
addCriterion("book_code <=", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeLike(String value) {
addCriterion("book_code like", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeNotLike(String value) {
addCriterion("book_code not like", value, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeIn(List<String> values) {
addCriterion("book_code in", values, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeNotIn(List<String> values) {
addCriterion("book_code not in", values, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeBetween(String value1, String value2) {
addCriterion("book_code between", value1, value2, "bookCode");
return (Criteria) this;
}
public Criteria andBookCodeNotBetween(String value1, String value2) {
addCriterion("book_code not between", value1, value2, "bookCode");
return (Criteria) this;
}
public Criteria andBookNameIsNull() {
addCriterion("book_name is null");
return (Criteria) this;
}
public Criteria andBookNameIsNotNull() {
addCriterion("book_name is not null");
return (Criteria) this;
}
public Criteria andBookNameEqualTo(String value) {
addCriterion("book_name =", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameNotEqualTo(String value) {
addCriterion("book_name <>", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameGreaterThan(String value) {
addCriterion("book_name >", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameGreaterThanOrEqualTo(String value) {
addCriterion("book_name >=", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameLessThan(String value) {
addCriterion("book_name <", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameLessThanOrEqualTo(String value) {
addCriterion("book_name <=", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameLike(String value) {
addCriterion("book_name like", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameNotLike(String value) {
addCriterion("book_name not like", value, "bookName");
return (Criteria) this;
}
public Criteria andBookNameIn(List<String> values) {
addCriterion("book_name in", values, "bookName");
return (Criteria) this;
}
public Criteria andBookNameNotIn(List<String> values) {
addCriterion("book_name not in", values, "bookName");
return (Criteria) this;
}
public Criteria andBookNameBetween(String value1, String value2) {
addCriterion("book_name between", value1, value2, "bookName");
return (Criteria) this;
}
public Criteria andBookNameNotBetween(String value1, String value2) {
addCriterion("book_name not between", value1, value2, "bookName");
return (Criteria) this;
}
public Criteria andBookTypeIsNull() {
addCriterion("book_type is null");
return (Criteria) this;
}
public Criteria andBookTypeIsNotNull() {
addCriterion("book_type is not null");
return (Criteria) this;
}
public Criteria andBookTypeEqualTo(Integer value) {
addCriterion("book_type =", value, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeNotEqualTo(Integer value) {
addCriterion("book_type <>", value, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeGreaterThan(Integer value) {
addCriterion("book_type >", value, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("book_type >=", value, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeLessThan(Integer value) {
addCriterion("book_type <", value, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeLessThanOrEqualTo(Integer value) {
addCriterion("book_type <=", value, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeIn(List<Integer> values) {
addCriterion("book_type in", values, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeNotIn(List<Integer> values) {
addCriterion("book_type not in", values, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeBetween(Integer value1, Integer value2) {
addCriterion("book_type between", value1, value2, "bookType");
return (Criteria) this;
}
public Criteria andBookTypeNotBetween(Integer value1, Integer value2) {
addCriterion("book_type not between", value1, value2, "bookType");
return (Criteria) this;
}
public Criteria andBookAtuthorIsNull() {
addCriterion("book_atuthor is null");
return (Criteria) this;
}
public Criteria andBookAtuthorIsNotNull() {
addCriterion("book_atuthor is not null");
return (Criteria) this;
}
public Criteria andBookAtuthorEqualTo(String value) {
addCriterion("book_atuthor =", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorNotEqualTo(String value) {
addCriterion("book_atuthor <>", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorGreaterThan(String value) {
addCriterion("book_atuthor >", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorGreaterThanOrEqualTo(String value) {
addCriterion("book_atuthor >=", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorLessThan(String value) {
addCriterion("book_atuthor <", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorLessThanOrEqualTo(String value) {
addCriterion("book_atuthor <=", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorLike(String value) {
addCriterion("book_atuthor like", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorNotLike(String value) {
addCriterion("book_atuthor not like", value, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorIn(List<String> values) {
addCriterion("book_atuthor in", values, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorNotIn(List<String> values) {
addCriterion("book_atuthor not in", values, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorBetween(String value1, String value2) {
addCriterion("book_atuthor between", value1, value2, "bookAtuthor");
return (Criteria) this;
}
public Criteria andBookAtuthorNotBetween(String value1, String value2) {
addCriterion("book_atuthor not between", value1, value2, "bookAtuthor");
return (Criteria) this;
}
public Criteria andPublishPressIsNull() {
addCriterion("publish_press is null");
return (Criteria) this;
}
public Criteria andPublishPressIsNotNull() {
addCriterion("publish_press is not null");
return (Criteria) this;
}
public Criteria andPublishPressEqualTo(String value) {
addCriterion("publish_press =", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressNotEqualTo(String value) {
addCriterion("publish_press <>", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressGreaterThan(String value) {
addCriterion("publish_press >", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressGreaterThanOrEqualTo(String value) {
addCriterion("publish_press >=", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressLessThan(String value) {
addCriterion("publish_press <", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressLessThanOrEqualTo(String value) {
addCriterion("publish_press <=", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressLike(String value) {
addCriterion("publish_press like", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressNotLike(String value) {
addCriterion("publish_press not like", value, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressIn(List<String> values) {
addCriterion("publish_press in", values, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressNotIn(List<String> values) {
addCriterion("publish_press not in", values, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressBetween(String value1, String value2) {
addCriterion("publish_press between", value1, value2, "publishPress");
return (Criteria) this;
}
public Criteria andPublishPressNotBetween(String value1, String value2) {
addCriterion("publish_press not between", value1, value2, "publishPress");
return (Criteria) this;
}
public Criteria andPublishDateIsNull() {
addCriterion("publish_date is null");
return (Criteria) this;
}
public Criteria andPublishDateIsNotNull() {
addCriterion("publish_date is not null");
return (Criteria) this;
}
public Criteria andPublishDateEqualTo(Date value) {
addCriterionForJDBCDate("publish_date =", value, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateNotEqualTo(Date value) {
addCriterionForJDBCDate("publish_date <>", value, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateGreaterThan(Date value) {
addCriterionForJDBCDate("publish_date >", value, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateGreaterThanOrEqualTo(Date value) {
addCriterionForJDBCDate("publish_date >=", value, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateLessThan(Date value) {
addCriterionForJDBCDate("publish_date <", value, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateLessThanOrEqualTo(Date value) {
addCriterionForJDBCDate("publish_date <=", value, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateIn(List<Date> values) {
addCriterionForJDBCDate("publish_date in", values, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateNotIn(List<Date> values) {
addCriterionForJDBCDate("publish_date not in", values, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateBetween(Date value1, Date value2) {
addCriterionForJDBCDate("publish_date between", value1, value2, "publishDate");
return (Criteria) this;
}
public Criteria andPublishDateNotBetween(Date value1, Date value2) {
addCriterionForJDBCDate("publish_date not between", value1, value2, "publishDate");
return (Criteria) this;
}
public Criteria andIsBorrowIsNull() {
addCriterion("is_borrow is null");
return (Criteria) this;
}
public Criteria andIsBorrowIsNotNull() {
addCriterion("is_borrow is not null");
return (Criteria) this;
}
public Criteria andIsBorrowEqualTo(Integer value) {
addCriterion("is_borrow =", value, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowNotEqualTo(Integer value) {
addCriterion("is_borrow <>", value, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowGreaterThan(Integer value) {
addCriterion("is_borrow >", value, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowGreaterThanOrEqualTo(Integer value) {
addCriterion("is_borrow >=", value, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowLessThan(Integer value) {
addCriterion("is_borrow <", value, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowLessThanOrEqualTo(Integer value) {
addCriterion("is_borrow <=", value, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowIn(List<Integer> values) {
addCriterion("is_borrow in", values, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowNotIn(List<Integer> values) {
addCriterion("is_borrow not in", values, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowBetween(Integer value1, Integer value2) {
addCriterion("is_borrow between", value1, value2, "isBorrow");
return (Criteria) this;
}
public Criteria andIsBorrowNotBetween(Integer value1, Integer value2) {
addCriterion("is_borrow not between", value1, value2, "isBorrow");
return (Criteria) this;
}
public Criteria andCreatedbyIsNull() {
addCriterion("createdBy is null");
return (Criteria) this;
}
public Criteria andCreatedbyIsNotNull() {
addCriterion("createdBy is not null");
return (Criteria) this;
}
public Criteria andCreatedbyEqualTo(String value) {
addCriterion("createdBy =", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyNotEqualTo(String value) {
addCriterion("createdBy <>", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyGreaterThan(String value) {
addCriterion("createdBy >", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyGreaterThanOrEqualTo(String value) {
addCriterion("createdBy >=", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyLessThan(String value) {
addCriterion("createdBy <", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyLessThanOrEqualTo(String value) {
addCriterion("createdBy <=", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyLike(String value) {
addCriterion("createdBy like", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyNotLike(String value) {
addCriterion("createdBy not like", value, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyIn(List<String> values) {
addCriterion("createdBy in", values, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyNotIn(List<String> values) {
addCriterion("createdBy not in", values, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyBetween(String value1, String value2) {
addCriterion("createdBy between", value1, value2, "createdby");
return (Criteria) this;
}
public Criteria andCreatedbyNotBetween(String value1, String value2) {
addCriterion("createdBy not between", value1, value2, "createdby");
return (Criteria) this;
}
public Criteria andCreationTimeIsNull() {
addCriterion("creation_time is null");
return (Criteria) this;
}
public Criteria andCreationTimeIsNotNull() {
addCriterion("creation_time is not null");
return (Criteria) this;
}
public Criteria andCreationTimeEqualTo(Date value) {
addCriterionForJDBCDate("creation_time =", value, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeNotEqualTo(Date value) {
addCriterionForJDBCDate("creation_time <>", value, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeGreaterThan(Date value) {
addCriterionForJDBCDate("creation_time >", value, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeGreaterThanOrEqualTo(Date value) {
addCriterionForJDBCDate("creation_time >=", value, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeLessThan(Date value) {
addCriterionForJDBCDate("creation_time <", value, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeLessThanOrEqualTo(Date value) {
addCriterionForJDBCDate("creation_time <=", value, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeIn(List<Date> values) {
addCriterionForJDBCDate("creation_time in", values, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeNotIn(List<Date> values) {
addCriterionForJDBCDate("creation_time not in", values, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeBetween(Date value1, Date value2) {
addCriterionForJDBCDate("creation_time between", value1, value2, "creationTime");
return (Criteria) this;
}
public Criteria andCreationTimeNotBetween(Date value1, Date value2) {
addCriterionForJDBCDate("creation_time not between", value1, value2, "creationTime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeIsNull() {
addCriterion("last_updatetime is null");
return (Criteria) this;
}
public Criteria andLastUpdatetimeIsNotNull() {
addCriterion("last_updatetime is not null");
return (Criteria) this;
}
public Criteria andLastUpdatetimeEqualTo(Date value) {
addCriterionForJDBCDate("last_updatetime =", value, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeNotEqualTo(Date value) {
addCriterionForJDBCDate("last_updatetime <>", value, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeGreaterThan(Date value) {
addCriterionForJDBCDate("last_updatetime >", value, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeGreaterThanOrEqualTo(Date value) {
addCriterionForJDBCDate("last_updatetime >=", value, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeLessThan(Date value) {
addCriterionForJDBCDate("last_updatetime <", value, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeLessThanOrEqualTo(Date value) {
addCriterionForJDBCDate("last_updatetime <=", value, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeIn(List<Date> values) {
addCriterionForJDBCDate("last_updatetime in", values, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeNotIn(List<Date> values) {
addCriterionForJDBCDate("last_updatetime not in", values, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeBetween(Date value1, Date value2) {
addCriterionForJDBCDate("last_updatetime between", value1, value2, "lastUpdatetime");
return (Criteria) this;
}
public Criteria andLastUpdatetimeNotBetween(Date value1, Date value2) {
addCriterionForJDBCDate("last_updatetime not between", value1, value2, "lastUpdatetime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | [
"3525801900@qq.com"
] | 3525801900@qq.com |
8f49bbf14d9ae2cc3c186bb07ad2798db9c98336 | 349efa251a79c2a1d25b593cd2a22a5cfa6d0eea | /src/main/java/com/thinkgem/jeesite/common/persistence/dialect/db/OracleDialect.java | db61d93d5b3fefaef3bd9e24cbd9b9613b17fffd | [] | no_license | geyanfeng/oa_system | a1b7406723fd6f48de54115e9af7194fe30e4f05 | 28efa3cecea687cbbd09dacf06bf61074f9f2933 | refs/heads/master | 2021-01-25T06:10:09.592340 | 2017-06-02T08:32:23 | 2017-06-02T08:32:23 | 93,533,627 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,223 | java | /**
*
*/
package com.thinkgem.jeesite.common.persistence.dialect.db;
import com.thinkgem.jeesite.common.persistence.dialect.Dialect;
/**
* Oracle的方言实现
* @author poplar.yfyang
* @version 1.0 2010-10-10 下午12:31
* @since JDK 1.5
*/
public class OracleDialect implements Dialect {
@Override
public boolean supportsLimit() {
return true;
}
@Override
public String getLimitString(String sql, int offset, int limit) {
return getLimitString(sql, offset, Integer.toString(offset), Integer.toString(limit));
}
/**
* 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换.
* <pre>
* 如mysql
* dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
* select * from user limit :offset,:limit
* </pre>
*
* @param sql 实际SQL语句
* @param offset 分页开始纪录条数
* @param offsetPlaceholder 分页开始纪录条数-占位符号
* @param limitPlaceholder 分页纪录条数占位符号
* @return 包含占位符的分页sql
*/
public String getLimitString(String sql, int offset, String offsetPlaceholder, String limitPlaceholder) {
sql = sql.trim();
boolean isForUpdate = false;
if (sql.toLowerCase().endsWith(" for update")) {
sql = sql.substring(0, sql.length() - 11);
isForUpdate = true;
}
StringBuilder pagingSelect = new StringBuilder(sql.length() + 100);
if (offset > 0) {
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
} else {
pagingSelect.append("select * from ( ");
}
pagingSelect.append(sql);
if (offset > 0) {
String endString = offsetPlaceholder + "+" + limitPlaceholder;
pagingSelect.append(" ) row_ where rownum <= "+endString+") where rownum_ > ").append(offsetPlaceholder);
} else {
pagingSelect.append(" ) where rownum <= "+limitPlaceholder);
}
if (isForUpdate) {
pagingSelect.append(" for update");
}
return pagingSelect.toString();
}
}
| [
"frank.tan8@live.com"
] | frank.tan8@live.com |
0229031fbf428fa37de606c68aa93b2f268c7a09 | 22da81306731463a4109581cdb4e78f20181cb8c | /IsomorphicString/src/com/ld/IsomorphicString.java | 4b117737e6b0784ad186f7757482bb037d3958e0 | [] | no_license | lijod/development | 723f88192657cd877a2fcee3262efca3f6147e16 | 42792dee1d002279696796994939026200ef22c8 | refs/heads/master | 2021-01-22T11:32:13.287564 | 2016-10-29T04:30:59 | 2016-10-29T04:30:59 | 53,348,915 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 927 | java | package com.ld;
import java.util.HashMap;
import java.util.Map;
public class IsomorphicString {
public static void main (String[] args) {
String s = "add";
String t = "egg";
System.out.println(isIsomorphic(s, t));
}
private static boolean isIsomorphic (String s, String t) {
if (s == null || t == null) {
return false;
}
if (s.length() != t.length()) {
return false;
}
Map<Character, Character> charMap = new HashMap<>();
for (int i = 0; i < s.length(); i++) {
Character c1 = s.charAt(i);
Character c2 = s.charAt(i);
if (charMap.containsKey(c1)) {
if (c2.equals(charMap.get(c1))) {
continue;
} else {
return false;
}
} else {
// Already mapped with other character
if (charMap.containsValue(c2)) {
return false;
}
charMap.put(c1, c2);
}
}
return true;
}
}
| [
"lijo_daniel90@yahoo.com"
] | lijo_daniel90@yahoo.com |
d49440149c5e5124e1c294615dc163f5d3b6793d | de895b9035054ee09140978140e5e9c98235c1e5 | /Auto/src/test/java/Auto/Auto/FilePro.java | e6585af2bce146ae18df8caaead6ee69c3a60665 | [] | no_license | Rakhi-bhagwate/Automation | 20fa56ede99546dac3a8de33a3112918ba03af9a | a45b46b5e86887be211fd45384700ae3460b9506 | refs/heads/master | 2020-12-19T12:32:05.069410 | 2020-01-28T07:34:29 | 2020-01-28T07:34:29 | 235,734,751 | 0 | 0 | null | 2020-10-13T19:01:50 | 2020-01-23T06:13:59 | HTML | UTF-8 | Java | false | false | 1,467 | java | package Auto.Auto;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class FilePro {
public static WebDriver driver;
@Test
public void openBrowser() throws FileNotFoundException, InterruptedException {
System. setProperty("webdriver.chrome.driver", "D:\\chromedriver_win32\\chromedriver.exe");
driver=new ChromeDriver();
// using properties to create object
Properties property = new Properties();
// Call the file OR.properties file
FileInputStream objFile = new FileInputStream("D:\\workspace\\Auto\\UP.properties");
// load the properties file
try {
property.load(objFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.get(property.getProperty("url"));
driver.manage().window().maximize();
System.out.println("Window is maximised");
driver.findElement(By.xpath("//*[@id=\"txtUsername\"]")).sendKeys(property.getProperty("username"));
System.out.println("name is entered");
driver.findElement(By.xpath("//*[@id=\"txtPassword\"]")).sendKeys(property.getProperty("password"));
System.out.println("password is entered");
driver.findElement(By.xpath("//*[@id=\"btnLogin\"]")).click();
System.out.println("submit is clicked");
}
}
| [
"rakhi.bhagwate@valuelabs.com"
] | rakhi.bhagwate@valuelabs.com |
6c24273b553bee2313ca247adb9398283a130471 | 61e4909154193e4303af53ba851b62cf03041c2f | /core/src/ru/pelmegov/screen/AbstractScreen.java | 882e954fa7e20f490f4f1e3697f0929d89832eb2 | [] | no_license | pelmegov/survive-java | 55eeee8889273fb2e1f1eec866201445d8472c3c | 1845a6f3374f8ba57c579ae1a0e2884c32595ad5 | refs/heads/master | 2020-07-19T05:39:59.230500 | 2019-09-22T16:14:21 | 2019-09-22T16:14:21 | 206,383,961 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 122 | java | package ru.pelmegov.screen;
import com.badlogic.gdx.Screen;
public abstract class AbstractScreen implements Screen {
}
| [
"pelmegovsa@gmail.com"
] | pelmegovsa@gmail.com |
8c99bbe54f3d7668ba659b11ba1cd2f441d9a1d8 | dd5bb1bdad8d4f94428057292fa3dcfca7efec3b | /ValueAtRisk/src/main/java/com/amundi/am/App.java | f34ff0ac692350b49fdb05262fe1eec0d31620d0 | [] | no_license | Ala92/ValueAtRisk | b18d74402cf97c43ae43535076c90ae365ab31ae | dfbed6b7769a7118eb5a5f043895af07b539d6b5 | refs/heads/master | 2021-06-24T10:36:13.552464 | 2019-11-11T15:42:51 | 2019-11-11T15:42:51 | 221,010,242 | 0 | 0 | null | 2021-04-26T19:41:21 | 2019-11-11T15:23:34 | Java | UTF-8 | Java | false | false | 1,813 | java | package com.amundi.am;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import com.amundi.am.entities.PortfolioValuation;
import com.amundi.am.exceptions.NotEnoughDataToProcessException;
import com.amundi.am.utils.CsvReader;
import com.amundi.am.utils.DateConverter;
import com.amundi.am.utils.InputReader;
public class App {
public static void main(String[] args) {
DateConverter converter = new DateConverter();
InputReader input = new InputReader(converter);
LocalDate minDate = input.getCurrentDate().minusDays(input.getHistoricalDepth());
List<PortfolioValuation> portfolioValuations = new CsvReader(converter).readValuesFromCsvFile(input
.getCsvFilePath(), minDate, input.getCurrentDate() );
try {
double estimatedVaR = calculateValueAtRist(portfolioValuations, input.getPercentileCoefficient());
System.out.println("The estimated VaR = " + estimatedVaR);
} catch (NotEnoughDataToProcessException e) {
System.out.println("Not enough Data");
}
}
/**
* calculates the value at risk given a list of portfolioValuations and
* the percentile coefficient
* @param portfolioValuations
* @param percentileCoefficient
* @return
* @throws NotEnoughDataToProcessException
*/
public static Double calculateValueAtRist(
List<PortfolioValuation> portfolioValuations,
int percentileCoefficient) throws NotEnoughDataToProcessException {
if (portfolioValuations == null || portfolioValuations.size() == 0) {
throw new NotEnoughDataToProcessException();
}
Collections.sort(
portfolioValuations,
(pv1, pv2) -> Double.compare(pv2.getValuation(),
pv1.getValuation()));
int index = Math.round(12f * percentileCoefficient / 100);
return portfolioValuations.get(index == 0? index : index - 1).getValuation();
}
} | [
"alachaabouni@gmail.com"
] | alachaabouni@gmail.com |
c9eac8a39b6282dd8dfe889b8f5742a60d8e6da2 | ee02f637eb28a798ca16d940f22ee4c4d6afe21e | /src/homeworks/lesson_5/controller/Controller.java | f0d155b58dd456e0c37ee998131bd4ca4ff541ed | [] | no_license | SytnykRoma/JavaSummer2021SytnykRO | 7f8de4808b2b4adc0eb0fad0dfbbb6c00dbdaf89 | e1323ca2d7958fc620782b08cd24c6d7426bfcc6 | refs/heads/main | 2023-06-17T15:01:21.399717 | 2021-07-14T14:05:57 | 2021-07-14T14:05:57 | 380,230,417 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,720 | java | package homeworks.lesson_5.controller;
import homeworks.lesson_5.model.Model;
import homeworks.lesson_5.view.View;
import static homeworks.lesson_5.controller.RegexContainer.*;
import static homeworks.lesson_5.view.TextConstants.*;
import java.util.Scanner;
/**
* Created by student on 07.07.2021.
*/
public class Controller {
private Model model;
private View view;
public Controller(Model model, View view) {
this.model = model;
this.view = view;
}
public void processUser() {
Scanner inputFields = new Scanner(System.in);
String lastname;
String nickname;
String str = (String.valueOf(View.bundle.getLocale()).equals("ua")) ? REGEX_LASTNAME_UKR : REGEX_LASTNAME_LAT;
view.printMessage(view.bundle.getString(START));
view.printMessage(view.bundle.getString(INPUT_LASTNAME));
lastname = validationForInput(inputFields, str);
model.setLastname(lastname);
view.printMessage(view.bundle.getString(INPUT_NICKNAME));
nickname = validationForInput(inputFields, REGEX_NICKNAME);
model.setNickname(nickname);
view.printResult(model.getLastname(), model.getNickname());
}
public String validationForInput(Scanner scanner, String regex) {
String inputTry;
boolean restartValidation = false;
do {
inputTry = scanner.next();
if (inputTry.matches(regex)) {
restartValidation = false;
}
else {
view.printMessage(view.bundle.getString(INPUT_ERROR));
restartValidation = true;
}
} while (restartValidation);
return inputTry;
}
}
| [
"sytnykroma.studyua@gmail.com"
] | sytnykroma.studyua@gmail.com |
27e0b216776994bacecb18c0bee5706e350537bf | 4e514efaaf965d866c16b2db7466129fe6ae3961 | /soluciones/06_Numeros_aleatorios/S06Ejercicio32alt.java | 68327d72dae7b2fc03050d5668b27bfeb836d73f | [] | no_license | LuisJoseSanchez/aprende-java-con-ejercicios | 60e866c755d5084caa1b70cff9218825d6848cd6 | a15e1a43a4a47b63423627e43360edd67dbb9433 | refs/heads/master | 2023-05-31T14:13:00.959474 | 2023-05-16T10:44:21 | 2023-05-16T10:44:21 | 16,025,190 | 324 | 306 | null | 2018-01-14T15:38:57 | 2014-01-18T12:39:52 | Java | UTF-8 | Java | false | false | 1,152 | java | import java.util.Scanner;
public class S06Ejercicio32alt {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Introduzca la longitud del sendero en metros: ");
int longitudSendero = Integer.parseInt(s.nextLine());
int espaciosPorDelante = 6;
for (int i = 0; i < longitudSendero; i++) {
// Espacios por delante
for (int j = 0; j < espaciosPorDelante; j++) {
System.out.print(' ');
}
// Borde izquierdo del sendero
System.out.print("🌴");
// Parte interior del sendero
int posicionObstaculo = -1;
String obstaculo = "🌿"; // planta por defecto
if ((int) (Math.random() * 2) == 0) { // hay obstáculo
posicionObstaculo = (int) (Math.random() * 4);
if ((int) (Math.random() * 2) == 0) { // piedra
obstaculo = "💎";
}
}
for (int j = 0; j < 4; j++) {
System.out.print(j == posicionObstaculo ? obstaculo : ' ');
}
// Borde derecho del sendero
System.out.println("🌴");
espaciosPorDelante += (int) (Math.random() * 3) - 1;
}
}
}
| [
"luisjoseprofe@gmail.com"
] | luisjoseprofe@gmail.com |
ac4cb12dc8fc48798b816ddecec1aac93f890b3d | 88db3f9a6349f38e3c57e5993811e39ddbc7c69a | /app/src/main/java/com/warunya/ricenearby/ui/profile/edit/EditProfileActivity.java | 777d3a8b8ad0827a8797bb68460db4819e61646f | [] | no_license | supagornpi/RiceNearby | e0559082e53bb4a423e55eaa3931515bf1630814 | 1ad3a95d9bc2e3ebe65a9383a504907eb06797d3 | refs/heads/master | 2020-04-11T06:13:46.219280 | 2019-03-30T11:50:19 | 2019-03-30T11:50:19 | 161,574,972 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,051 | java | package com.warunya.ricenearby.ui.profile.edit;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import com.warunya.ricenearby.MyApplication;
import com.warunya.ricenearby.R;
import com.warunya.ricenearby.base.AbstractActivity;
import com.warunya.ricenearby.constant.Gender;
import com.warunya.ricenearby.model.User;
import com.warunya.ricenearby.ui.address.AddressActivity;
import com.warunya.ricenearby.utils.DismissKeyboardListener;
import com.warunya.ricenearby.utils.FileUtils;
import com.warunya.ricenearby.utils.GlideLoader;
import com.warunya.ricenearby.utils.IntentUtils;
import com.warunya.ricenearby.utils.PermissionUtils;
import com.warunya.ricenearby.utils.SpinnerUtils;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import static com.warunya.ricenearby.constant.AppInstance.DATE_FORMAT_BIRTHDATE;
public class EditProfileActivity extends AbstractActivity implements EditProfileContract.View {
private static final int REQUEST_IMAGE_GALLERY = 1;
private Uri imageUri = null;
private EditProfileContract.Presenter presenter = new EditProfilePresenter(this);
private String currentSelectedDate = "";
private Calendar myCalendar = Calendar.getInstance();
private Button btnEditProfile;
private TextView tvUsername;
private TextView tvEmail;
private EditText edtName;
private EditText edtMobile;
private TextView tvBirthday;
private TextView tvGender;
private TextView tvAddress;
private Spinner spnGender;
private ImageView ivProfile;
private LinearLayout layoutAddress;
private LinearLayout layoutRootView;
private ScrollView scrollView;
public static void start() {
Intent intent = new Intent(MyApplication.applicationContext, EditProfileActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MyApplication.applicationContext.startActivity(intent);
}
@Override
protected int setLayoutView() {
return R.layout.activity_edit_profile;
}
@Override
protected void setupView(Bundle savedInstanceState) {
setTitle("");
setToolbarColor(android.R.color.transparent);
showBackButton();
bindView();
bindAction();
presenter.start();
myCalendar.set(Calendar.YEAR, 1990);
}
@Override
protected void onResume() {
super.onResume();
presenter.getAddress();
}
private void bindView() {
btnEditProfile = findViewById(R.id.btn_edit_profile);
tvUsername = findViewById(R.id.tv_username);
edtName = findViewById(R.id.edt_name);
tvEmail = findViewById(R.id.tv_email);
edtMobile = findViewById(R.id.edt_mobile);
tvBirthday = findViewById(R.id.tv_birthday);
tvGender = findViewById(R.id.tv_gender);
spnGender = findViewById(R.id.spinner_gender);
ivProfile = findViewById(R.id.iv_profile);
tvAddress = findViewById(R.id.tv_address);
layoutAddress = findViewById(R.id.layout_address);
layoutRootView = findViewById(R.id.rootView);
scrollView = findViewById(R.id.scrollView);
SpinnerUtils.setSpinner(getApplicationContext(), spnGender, R.array.gender_list, true);
}
private void bindAction() {
layoutRootView.setOnTouchListener(new DismissKeyboardListener(this));
scrollView.setOnTouchListener(new DismissKeyboardListener(this));
btnEditProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
presenter.editUserProfile(getUserProfile());
}
});
ivProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openGalleryIntent();
}
});
layoutAddress.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AddressActivity.start();
}
});
tvBirthday.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDatePickerDialog();
}
});
tvGender.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
spnGender.performClick();
}
});
spnGender.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
tvGender.setText(spnGender.getSelectedItem().toString());
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
@Override
public void error(@NotNull String message) {
}
@Override
public void bindUserData(User user) {
tvUsername.setText(user.username);
edtName.setText(user.name);
tvEmail.setText(user.email);
edtMobile.setText(user.mobile);
if (user.birthday != null) {
currentSelectedDate = user.birthday;
tvBirthday.setText(user.birthday);
}
if (user.image == null) return;
GlideLoader.loadImageCircle(user.image.url, ivProfile);
if (user.gender != null) {
if (user.gender == Gender.Male) {
spnGender.setSelection(1);
} else if (user.gender == Gender.Female) {
spnGender.setSelection(2);
}
}
}
@Override
public void bindAddress(User user) {
if (user.addresses != null && user.addresses.size() > 0) {
tvAddress.setText(user.addresses.get(0).name);
}
}
private User getUserProfile() {
String username = tvUsername.getText().toString().trim();
String name = edtName.getText().toString().trim();
String mobile = edtMobile.getText().toString().trim();
String birthday = currentSelectedDate;
Gender gender = Gender.parse(spnGender.getSelectedItemPosition());
File file = null;
if (imageUri != null) {
file = FileUtils.getResizedBitmap(this, new File(FileUtils.getRealPathFromURI(this, imageUri)));
}
return new User(username, name, mobile, gender, birthday, file == null ? null : Uri.fromFile(file));
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_IMAGE_GALLERY && data != null) {
imageUri = data.getData();
GlideLoader.loadImageCircle(imageUri, ivProfile);
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PermissionUtils.PERMISSION_READ_EXTERNAL_STORAGE) {
if (PermissionUtils.isGrantAll(permissions)) {
openGalleryIntent();
}
}
}
private void openGalleryIntent() {
IntentUtils.startIntentGallery(this, REQUEST_IMAGE_GALLERY);
}
private void showDatePickerDialog() {
final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
}
};
new DatePickerDialog(EditProfileActivity.this, date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
private void updateLabel() {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_BIRTHDATE, new Locale("th"));
currentSelectedDate = sdf.format(myCalendar.getTime());
tvBirthday.setText(currentSelectedDate);
}
}
| [
"supagorn.pi@gmail.com"
] | supagorn.pi@gmail.com |
cea863112efdcb6a2f423c7a352ad69fd61f5339 | 58d4fdf03133183cb67c24aae95662e42579554d | /src/main/java/com/soraxus/prisons/luckyblocks/ModuleLuckyBlocks.java | 55ee46e62de5279a46dca785c2c3af49b94c4a09 | [] | no_license | mattlack15/PrisonCore | e2aa969293efaff0812e898cda90d17dac06b880 | 9895aa6c246d0064dbc9b01f72ae5cd8661b9758 | refs/heads/master | 2023-06-21T17:10:25.909666 | 2021-08-01T04:17:35 | 2021-08-01T04:17:35 | 374,835,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,347 | java | package com.soraxus.prisons.luckyblocks;
import com.soraxus.prisons.core.CoreModule;
import com.soraxus.prisons.economy.Economy;
import com.soraxus.prisons.enchants.api.enchant.AbstractCE;
import com.soraxus.prisons.enchants.customenchants.Favored;
import com.soraxus.prisons.enchants.gui.MenuEnchant;
import com.soraxus.prisons.enchants.manager.EnchantManager;
import com.soraxus.prisons.event.PrisonBlockBreakEvent;
import com.soraxus.prisons.util.EventSubscription;
import com.soraxus.prisons.util.NumberUtils;
import com.soraxus.prisons.util.display.chat.ChatBuilder;
import com.soraxus.prisons.util.display.chat.ClickUtil;
import com.soraxus.prisons.util.display.chat.HoverUtil;
import com.soraxus.prisons.util.math.MathUtils;
import com.soraxus.prisons.util.menus.MenuElement;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class ModuleLuckyBlocks extends CoreModule {
public void runLuckyBlock(Player player) {
ItemStack pick = player.getInventory().getItemInMainHand();
AbstractCE favored = EnchantManager.instance.getCE(Favored.class);
int level = favored.getLevel(pick) + 1;
double rand = MathUtils.random(0, 100D);
if (rand <= 30.0) { // Money
long money = (long) Math.floor(1000 * ((level / 25D) + 1));
Economy.money.addBalance(player.getUniqueId(), money);
player.sendMessage("§eLucky Blocks > §7You have received §e$" + NumberUtils.formatFull(money) + "§7.");
return;
}
long tokens = favored.getCost(level) / 50;
if (rand <= 65) { // Small tokens
tokens = favored.getCost(level) / 60;
}
ChatBuilder builder = new ChatBuilder("§eLucky Blocks > §7You have received §e" + NumberUtils.formatFull(tokens) + " Tokens§7.");
if (tokens == 0) {
builder.addText(" &7You need\nthe " + EnchantManager.instance.getCE(Favored.class).getDisplayName() + " &7enchant to get lucky block rewards!",
HoverUtil.text("&fClick to open&d enchant menu"),
ClickUtil.runnable((p) -> {
if (p.getInventory().getItemInMainHand() != null && p.getInventory().getItemInMainHand().getType().toString().contains("PICKAXE")) {
new MenuEnchant(p, p.getInventory().getItemInMainHand(), EnchantManager.instance.getEnchantments()).open(p);
} else {
p.playSound(p.getLocation(), Sound.ENTITY_ENDERDRAGON_HURT, 0.8f, 1.2f);
new ChatBuilder("&cYou must be holding your pickaxe to open the enchantment menu!").send(p);
}
}));
}
builder.send(player);
Economy.tokens.addBalance(player.getUniqueId(), tokens);
}
@Override
public String getName() {
return "Lucky Blocks";
}
@Override
public MenuElement getGUI(MenuElement backButton) {
return null;
}
@EventSubscription
public void onBreak(PrisonBlockBreakEvent e) {
if ((e.getBlock() & 4095) == Material.SPONGE.getId()) {
for (int i = 0; i < e.getAmount(); i++)
runLuckyBlock(e.getPlayer());
e.setAmount(0);
}
}
}
| [
"unconfigured@null.spigotmc.org"
] | unconfigured@null.spigotmc.org |
94898ba10329a0908ddd0851a685e0586488a207 | a4bdc3c2184ee43fd96690da352babd6a4e601bf | /app/src/androidTest/java/com/techease/newsapp/ExampleInstrumentedTest.java | 98c0e9a4c66cf7aa810815ad389e87b3e3f1de0d | [] | no_license | softwrengr/News_App | 6b7227386dc70405626007e11536f72836227cfd | a7436391872f679d953bbdee9edaff52317b5a6a | refs/heads/master | 2020-05-14T15:55:20.214608 | 2019-04-17T09:52:34 | 2019-04-17T09:52:34 | 181,863,137 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 724 | java | package com.techease.newsapp;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.techease.newsapp", appContext.getPackageName());
}
}
| [
"softwrengr@gmail.com"
] | softwrengr@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.