blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6649c90a6a68e77c3aae5c97346629c051e2bab3 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /api-vs-impl-small/core/src/main/java/org/gradle/testcore/performancenull_10/Productionnull_903.java | 63c3f162f31745130ea4b44106a1b16716ca1410 | [] | no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 587 | java | package org.gradle.testcore.performancenull_10;
public class Productionnull_903 {
private final String property;
public Productionnull_903(String param) {
this.property = param;
}
public String getProperty() {
return property;
}
private String prop0;
public String getProp0() {
return prop0;
}
public void setProp0(String value) {
prop0 = value;
}
private String prop1;
public String getProp1() {
return prop1;
}
public void setProp1(String value) {
prop1 = value;
}
}
| [
"[email protected]"
] | |
4bfea6d0b91b7f48d1d27ffce54d801f4ba76415 | d49120908d0ecfb05452e9f04fc168c9f38ea95f | /app/src/test/java/sadiq/raza/projectharvest/ExampleUnitTest.java | 9f534a615f3ca3f9169bb1b728b352972c261f70 | [] | no_license | SadiqKhanRaza/ProjectHarvest | 1c379044815368fd2bf1d3e7e4c447ace26c7509 | fdd64542f57f51d7c670cc471d9f2ad2a9afc529 | refs/heads/master | 2020-04-25T17:57:23.955831 | 2019-03-01T09:25:34 | 2019-03-01T09:25:34 | 172,967,348 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package sadiq.raza.projectharvest;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
310a6c1fc836499132feba14ba4eb54a834c1e7a | 52e82999b26ea658f96574021c0a653ab355eb95 | /src/main/java/com/example/spring/multidb/models/CommonBaseModel.java | cedd17a10223b1a3a93cd400f01b346fcfd37ab4 | [] | no_license | sureshpec04/multidbspring | 494b5e67e903e8b131ecd90547c49c40972de993 | cb82e514c2e902b4700b6c4469e3975966fc0887 | refs/heads/master | 2020-03-18T04:24:17.735100 | 2018-05-21T15:29:59 | 2018-05-21T15:29:59 | 134,285,378 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,749 | java | package com.example.spring.multidb.models;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
/** Abstract base model including primary id and
* created_at and updated_at time fields.
*/
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class CommonBaseModel {
/** Primary id. */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
/** Model created at timestamp. */
@CreatedDate
@Column(name = "created_at")
private Date createdAt;
/** Model updated at timestamp. */
@LastModifiedDate
@Column(name = "updated_at")
private Date updatedAt;
/** Constructor. */
protected CommonBaseModel() {
// Private constructor to prevent direct instantiation.
}
/** Primary id getter. */
public Long getId() {
return id;
}
/** Primary id setter. */
public void setId(final Long id) {
this.id = id;
}
/** Created at getter. */
public Date getCreatedAt() {
return (Date) createdAt.clone();
}
/** Created at setter. */
public void setCreatedAt(final Date createdAt) {
this.createdAt = (Date) createdAt.clone();
}
/** Updated at getter. */
public Date getUpdatedAt() {
return (Date) updatedAt.clone();
}
/** Updated at setter. */
public void setUpdatedAt(final Date updatedAt) {
this.updatedAt = (Date) updatedAt.clone();
}
}
| [
"[email protected]"
] | |
a55a416d42e488d944b3633c36425adc6c88b30a | 649850df39bab4b699a9be75b7bb428f7a90aaf6 | /app/src/main/java/cn/dlc/wifilistdemo/PasswordDialog.java | 0aa9c81f7e72819f0577788e90f51ea1bd13c208 | [] | no_license | DlcAndroidTeam123456/WifiConnection | 1f6f2ad9744ffb12343dd6548183642530c5bfe6 | 45ce4927f2258fc64804d89fe140373936afe6e8 | refs/heads/master | 2020-09-14T07:42:58.471956 | 2019-11-21T02:19:06 | 2019-11-21T02:19:06 | 223,068,250 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,645 | java | package cn.dlc.wifilistdemo;
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by John on 2018/3/28.
*/
public class PasswordDialog extends Dialog {
@BindView(R.id.et_password)
EditText mEtPassword;
@BindView(R.id.btn_cancel)
Button mBtnCancel;
@BindView(R.id.btn_connect)
Button mBtnConnect;
private OnClickConnectListener mListener;
public interface OnClickConnectListener {
void toConnect(PasswordDialog dialog, String password);
}
public PasswordDialog(@NonNull Context context) {
super(context, R.style.CommonDialogStyle);
setContentView(R.layout.dialog_password);
ButterKnife.bind(this);
}
@OnClick({ R.id.btn_cancel, R.id.btn_connect })
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.btn_cancel:
dismiss();
break;
case R.id.btn_connect:
String password = mEtPassword.getText().toString();
if (mListener != null) {
mListener.toConnect(this, password);
}
break;
}
}
public void show(OnClickConnectListener listener) {
mListener = listener;
super.show();
}
@Override
public void show() {
super.show();
throw new RuntimeException("不要调用这个方法");
}
}
| [
"[email protected]"
] | |
d5d55b9055c775f1d78ac4f34581c19bb7537bcf | da7801451fdad67a239b7eb264c92efbd32f778f | /src/test/java/SoyTest.java | 13f19374eb2f60f563b19f2fabd052e910aa1fd9 | [] | no_license | stephanecharron/decorateur | 1afcd8213a9a0377f61339bc89ec3b95dea51654 | 95c56eed7d9d1e3c26f08d4a960a8a94e54c3644 | refs/heads/master | 2020-04-20T16:48:15.541424 | 2019-02-03T16:59:59 | 2019-02-03T16:59:59 | 168,967,193 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 468 | java | import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class SoyTest {
Beverage beverage = new Soy( new Mocha( new Espresso()));
@Test
public void cost() {
Double price = beverage.cost();
Double expectedPrice = 2.34;
assertEquals(expectedPrice, price);
}
@Test
public void getDescription() {
String s = beverage.getDescription();
assertEquals("Espresso, Mocha, Soy", s);
}
} | [
"[email protected]"
] | |
14c941644000dfd9181a90fb5ea8a0da2f0829a6 | a88112855489699b7bb53a1571066cecc186c976 | /src/main/java/rough/LoginPage.java | c4048a8ac0dea3bab9339a956485ed112a4f10be | [] | no_license | shikhaswaroop/Cucumber | eff0a875648de4f2d2674266278a79649a821e88 | 691146a5a125e3b344aa25aad40f8c6fea5ad307 | refs/heads/master | 2023-05-04T03:06:43.996858 | 2021-05-23T06:36:28 | 2021-05-23T06:36:28 | 369,845,120 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,494 | java | package rough;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import testbase.TestBase;
public class LoginPage {
public WebDriver driver;
public LoginPage(WebDriver driver){
this.driver = driver;
PageFactory.initElements(driver, this);
}
@FindBy(xpath="//input[@name='uid']")
public WebElement username_txtbox;
@FindBy(xpath="//input[@name='password']")
public WebElement password_txtbox;
@FindBy(name="btnLogin")
public WebElement login_btn;
@FindBy(xpath="//input[@name='btnReset']")
public WebElement reset_btn;
public void enterUserName(String username)
{
//wait_until_visibilityOfElement(username_txtbox);
username_txtbox.clear();
username_txtbox.sendKeys(username);
}
public void enterPassword(String password)
{
//wait_until_visibilityOfElement(password_txtbox);
password_txtbox.clear();
password_txtbox.sendKeys(password);
}
public void clickOnLogin()
{
//wait_until_visibilityOfElement(login_btn);
login_btn.click();
}
public void clickonResetbutton()
{
reset_btn.click();
}
public void verifyTitle(){
String title = driver.getTitle();
String expectedtitle = "Guru99 Bank Manager HomePage";
Assert.assertEquals(title,expectedtitle);
}
public String getAlertText(){
String text = driver.switchTo().alert().getText();
return text;
}
}
| [
"[email protected]"
] | |
c727688c578a529670d45670b9994c3c9375322e | 66631af1297ee9b00241454396422ba4c216fba6 | /Java/src/javaSyntax/Regex.java | 26d0e63287566902deb07ebae373bea4a15ecf58 | [] | no_license | Code-200-OK/fuzzy-carnival | b378f19df721a008af7f982ca87bd3bb12b1d323 | acf409bfdc15375a9885fc780a8ec6c504c87354 | refs/heads/master | 2020-12-02T07:54:27.549280 | 2017-07-11T08:04:07 | 2017-07-11T08:04:07 | 96,578,136 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 50 | java | package javaSyntax;
public class Regex {
}
| [
"[email protected]"
] | |
f708b96c05030c22a00763771f6e30d46615db87 | b824da283de89417361dd7d5b781fff8e3875a2d | /src/main/java/com/mycompany/cafeteriaweb/domain/Store.java | 52ba6372fcbfd8309e986e159293cfd53996ae7f | [] | no_license | ZandileN/RestRepo | 4bfdfeab373be027dbf3727ce90a027e959898ca | 6aed9a0eade1404a5058a71c284e870965589c11 | refs/heads/master | 2020-12-24T17:17:46.723552 | 2014-05-30T09:07:30 | 2014-05-30T09:07:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,923 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.cafeteriaweb.domain;
import com.mycompany.cafeteriaweb.domain.Help.Builder;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
/**
*
* @author Sibakhulu
*/
@Entity
public class Store implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String strname;
private int hoursOpen;
private String tel;
@Embedded
private Help help;
@OneToMany
@JoinColumn(name="cust_id")
private List <Customer> customer;
private Store(Builder builder) {
id = builder.id;
strname = builder.strname;
hoursOpen = builder.hoursOpen;
tel = builder.tel;
help = builder.help;
customer=builder.customer;
}
private Store() {
}
public static class Builder {
private long id;
private String strname;
private int hoursOpen;
private String tel;
private Help help;
private List <Customer> customer;
public Builder(String value) {
this.strname = value;
}
public Builder hoursOpen(int value) {
hoursOpen = value;
return this;
}
public Builder id(Long value) {
id = value;
return this;
}
public Builder tel(String value) {
tel = value;
return this;
}
public Builder help(Help value) {
help = value;
return this;
}
public Builder Customer(List <Customer> cust)
{
customer=cust;
return this;
}
public Builder copy(Store store) {
this.id=store.getId();
this.strname = store.getName();
this.hoursOpen = store.getHoursOpen();
this.tel = store.getTel();
this.help = store.getHelp();
this.customer= store.getCustomer();
return this;
}
public Store build() {
return new Store(this);
}
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getName() {
return strname;
}
public int getHoursOpen() {
return hoursOpen;
}
public String getTel() {
return tel;
}
public Help getHelp() {
return help;
}
public List <Customer> getCustomer() {
return customer;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Store)) {
return false;
}
Store other = (Store) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.mycompany.cafeteriaweb.domain.Store[ id=" + id + " ]";
}
}
| [
"Sibakhulu@Madlamini"
] | Sibakhulu@Madlamini |
6128c880e08fd60d94f0904d7575629fcaf8a521 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/12/12_2d07f9194af111c4a1b6b431f3a59798c43fb8c7/KeyManager/12_2d07f9194af111c4a1b6b431f3a59798c43fb8c7_KeyManager_s.java | 0b38a13e0cd01d3ba8a50deb22a4089a358cad7c | [] | 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 | 38,570 | java | /**
* Part of the CCNx Java Library.
*
* Copyright (C) 2008, 2009 Palo Alto Research Center, Inc.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. You should have received
* a copy of the GNU Lesser General Public License along with this library;
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.ccnx.ccn;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.security.InvalidKeyException;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.util.logging.Level;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.ccnx.ccn.config.ConfigurationException;
import org.ccnx.ccn.config.SystemConfiguration;
import org.ccnx.ccn.impl.CCNFlowControl;
import org.ccnx.ccn.impl.CCNFlowControl.SaveType;
import org.ccnx.ccn.impl.CCNFlowControl.Shape;
import org.ccnx.ccn.impl.repo.RepositoryFlowControl;
import org.ccnx.ccn.impl.security.keys.BasicKeyManager;
import org.ccnx.ccn.impl.security.keys.PublicKeyCache;
import org.ccnx.ccn.impl.security.keys.SecureKeyCache;
import org.ccnx.ccn.impl.support.Log;
import org.ccnx.ccn.impl.support.Tuple;
import org.ccnx.ccn.io.CCNReader;
import org.ccnx.ccn.io.ErrorStateException;
import org.ccnx.ccn.io.content.PublicKeyObject;
import org.ccnx.ccn.profiles.SegmentationProfile;
import org.ccnx.ccn.profiles.VersioningProfile;
import org.ccnx.ccn.profiles.security.KeyProfile;
import org.ccnx.ccn.profiles.security.access.AccessControlManager;
import org.ccnx.ccn.protocol.CCNTime;
import org.ccnx.ccn.protocol.ContentName;
import org.ccnx.ccn.protocol.ContentObject;
import org.ccnx.ccn.protocol.KeyLocator;
import org.ccnx.ccn.protocol.KeyName;
import org.ccnx.ccn.protocol.PublisherPublicKeyDigest;
import org.ccnx.ccn.protocol.ContentObject.SimpleVerifier;
import org.ccnx.ccn.protocol.KeyLocator.KeyLocatorType;
import org.ccnx.ccn.protocol.SignedInfo.ContentType;
/**
* Top-level interface for managing our own keys, as well as maintaining an address book containing
* the keys of others (which will be used by the TrustManager). Also handles loading of the BouncyCastle
* provider, which we need for many things. Very minimal interface now, expect to evolve extensively.
*/
public abstract class KeyManager {
static {
// This needs to be done once. Do it here to be sure it happens before
// any work that needs it.
KeyManager.initializeProvider();
}
/**
* Canary value, indicates we want to override any other key locator available.
*/
protected static final KeyLocator SELF_SIGNED_KEY_LOCATOR = new KeyLocator();
/**
* Currently default to SHA-256. Only thing that associates a specific digest algorithm
* with a version of the CCN protocol is the calculation of the vestigial content digest component
* of ContentName used in Interest matching, and publisher digests. Changing the latter
* is handled by backwards-compatible changes to the protocol encoding. All other digests are
* stored prefaced with an algorithm identifier, to allow them to be modified.
* We expect the protocol default digest algorithm to move to SHA3 when defined.
*/
public static final String DEFAULT_DIGEST_ALGORITHM = "SHA-256";
protected static Provider BC_PROVIDER = null;
/**
* The default KeyManager for this user/VM pair. The KeyManager will eventually have access
* to significant cached state, and so a single one should be shared by as many processes
* within the same trust domain as possible. We might make multiple KeyManagers representing
* different "users" for testing purposes.
*/
protected static KeyManager _defaultKeyManager = null;
/**
* A default verifier to use, relative to these key caches and all. Move to TrustManager eventually.
*/
protected ContentVerifier _verifier = null;
/**
* Accessor to retrieve default key manager instance, or create it if necessary.
* @return the KeyManager
* @throws ConfigurationException if there is a problem with the user or system configuration that
* requires intervention to resolve, or we have a significant problem starting up the key manager.
*/
public static synchronized KeyManager getDefaultKeyManager() {
// could print a stack trace
if (Log.isLoggable(Log.FAC_KEYS, Level.FINER)) {
Log.finer(Log.FAC_KEYS, "NOTICE: retrieving default key manager. Do you really want to do this?");
try {
throw new ConfigurationException("THIS IS NOT AN ERROR: tracking stack trace to find use of default key manager.");
} catch (ConfigurationException e) {
Log.logStackTrace(Level.FINER, e);
}
}
if (null != _defaultKeyManager)
return _defaultKeyManager;
try {
return createDefaultKeyManager();
} catch (IOException io) {
Log.warning("IOException attempting to get KeyManager: " + io.getClass().getName() + ":" + io.getMessage());
Log.warningStackTrace(io);
throw new RuntimeException("Error in system configuration. Cannot get KeyManager.",io);
} catch (InvalidKeyException io) {
Log.warning("InvalidKeyException attempting to get KeyManager: " + io.getClass().getName() + ":" + io.getMessage());
Log.warningStackTrace(io);
throw new RuntimeException("Error in system configuration. Cannot get KeyManager.",io);
} catch (ConfigurationException e) {
Log.warning("Configuration exception attempting to get KeyManager: " + e.getMessage());
Log.warningStackTrace(e);
throw new RuntimeException("Error in system configuration. Cannot get KeyManager.",e);
}
}
/**
* Clean up state left around by the default key manager and remove it.
* For now that just means shutting down the network manager started by it
*/
public static synchronized void closeDefaultKeyManager() {
if (null != _defaultKeyManager) {
_defaultKeyManager.close();
_defaultKeyManager = null;
}
}
/**
* Create the default key manager.
* @return the key manager
* @throws ConfigurationException if there is a problem with the user or system configuration
* that requires intervention to fix
* @throws IOException if there is an operational problem loading data or initializing the key store
* @throws ConfigurationException
*/
protected static synchronized KeyManager createDefaultKeyManager() throws InvalidKeyException, IOException, ConfigurationException {
if (null == _defaultKeyManager) {
_defaultKeyManager = new BasicKeyManager();
_defaultKeyManager.initialize();
}
return _defaultKeyManager;
}
/**
* Set the default key manager to one of our choice. If you do this, be careful on
* calling close().
*/
public static synchronized void setDefaultKeyManager(KeyManager keyManager) {
if (null == keyManager) {
Log.warning("Setting default key manager to NULL. Default user key manager will be loaded on next request for default key manager.");
}
closeDefaultKeyManager();
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Setting default key manager: new KeyManager {0}", keyManager.getClass().getName());
}
_defaultKeyManager = keyManager;
}
/**
* Load the BouncyCastle and other necessary providers, should be called once for initialization.
* Currently this is done by CCNHandle.
*/
public static void initializeProvider() {
synchronized(KeyManager.class) {
if (null == BC_PROVIDER) {
BC_PROVIDER = Security.getProvider("BC");
if (null == BC_PROVIDER) {
Provider bc = new BouncyCastleProvider();
int result = Security.addProvider(bc);
BC_PROVIDER = bc;
if (null != BC_PROVIDER) {
if (result > 0) {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "KeyManager: Successfully initialized BouncyCastle provider at position " + result);
}
} else {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "KeyManager: BouncyCastle provider already installed.");
}
}
} else {
Log.severe("ERROR: NULL default provider! Cannot load BouncyCastle! Result of addProvider: " + result);
}
} else {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "KeyManager: BouncyCastle provider installed by default.");
}
}
Provider checkProvider = Security.getProvider("BC");
if (null == checkProvider) {
Log.severe("Could not load BouncyCastle provider back in!");
}
}
}
}
/**
* Retrieve our default BouncyCastle provider.
* @return the BouncyCastle provider instance
*/
public static Provider getDefaultProvider() {
if (null == BC_PROVIDER) {
initializeProvider();
}
if (null == BC_PROVIDER) {
Log.severe("ERROR: NULL default provider! Cannot load BouncyCastle!");
}
return BC_PROVIDER;
}
public static boolean checkDefaultProvider() {
boolean test = true;
if (null == BC_PROVIDER) {
test = false;
Log.warning("checkDefaultProvider: initialization of BouncyCastle provider did not proceed properly, no BC_PROVIDER.");
}
if (null == Security.getProvider("BC")) {
test = false;
Log.warning("checkDefaultProvider: cannot load BouncyCastle provider!");
}
return test;
}
/**
* Subclasses can override with fancier verification behavior; again move to TrustManager eventually
*/
public ContentVerifier getDefaultVerifier() {
if (null == _verifier) {
synchronized(this) {
if (null == _verifier) {
_verifier = new SimpleVerifier(null, this);
}
}
}
return _verifier;
}
/**
* Close any connections we have to the network. Ideally prepare to
* reopen them when they are next needed.
*/
public abstract void close();
/**
* Allows subclasses to specialize key manager initialization.
* @throws ConfigurationException
* @throws IOException
*/
public abstract void initialize() throws InvalidKeyException, IOException, ConfigurationException;
public abstract boolean initialized();
public abstract void clearSavedConfigurationState() throws FileNotFoundException, IOException;
/**
* Get our default key ID.
* @return the digest of our default key
*/
public abstract PublisherPublicKeyDigest getDefaultKeyID();
public boolean isOurDefaultKey(PublisherPublicKeyDigest keyID) {
if (getDefaultKeyID().equals(keyID))
return true;
return false;
}
/**
* Access our collected store of public keys.
* @return our PublicKeyCache
*/
public abstract PublicKeyCache getPublicKeyCache();
/**
* Access our store of private keys and other secret key
* material that we have retrieved.
* @return our SecureKeyCache
*/
public abstract SecureKeyCache getSecureKeyCache();
public abstract void saveSecureKeyCache() throws FileNotFoundException, IOException;
public abstract void saveConfigurationState() throws FileNotFoundException,
IOException;
/**
* Not sure that this is the best idea, but others want to bootstrap on
* our configuration data store to stash their own config data. Return
* location as a URI as it might be a namespace rather than a directory.
*/
public abstract URI getConfigurationDataURI();
/**
* Get our default private key.
* @return our default private key
*/
public abstract PrivateKey getDefaultSigningKey();
/**
* Get our default public key.
* @return our default public key
*/
public abstract PublicKey getDefaultPublicKey();
/**
* Return the key's content name for a given key id, given
* a specified prefix and version.
* The default key name is the publisher ID itself,
* under the user's key collection.
* @param keyID[] publisher ID
* @return content name
*/
public ContentName getDefaultKeyName(ContentName keyPrefix, PublisherPublicKeyDigest keyID, CCNTime keyVersion) {
if (null == keyPrefix) {
keyPrefix = getDefaultKeyNamePrefix();
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Got default key name prefix: {0}", keyPrefix);
}
}
ContentName keyName = KeyProfile.keyName(keyPrefix, keyID);
if (null != keyVersion) {
return VersioningProfile.addVersion(keyName, keyVersion);
}
return keyName;
}
/**
* Get the key-manager determined default key name for a key. Might include
* a version, might allow caller to save with generated version.
*/
public abstract ContentName getDefaultKeyName(PublisherPublicKeyDigest keyID);
/**
* Allow subclasses to override default publishing location.
*/
public abstract ContentName getDefaultKeyNamePrefix();
/**
* Gets the preferred key locator for this signing key.
* @param publisherKeyID the key whose locator we want to retrieve,
* if null retrieves the key locator for our default key
* @return the current preferred key locator for that key
*/
public abstract KeyLocator getKeyLocator(PublisherPublicKeyDigest publisherKeyID);
/**
* Get our current preferred key locator for this signing key. Uses
* getKeyLocator(PublisherPublicKeyDigest).
*/
public abstract KeyLocator getKeyLocator(PrivateKey signingKey);
/**
* Get the key locator for our default key. Same as getKeyLocator(null)
*/
public KeyLocator getDefaultKeyLocator() {
return getKeyLocator(getDefaultKeyID());
}
public abstract boolean haveStoredKeyLocator(PublisherPublicKeyDigest keyID);
public abstract KeyLocator getStoredKeyLocator(PublisherPublicKeyDigest keyID);
public abstract void clearStoredKeyLocator(PublisherPublicKeyDigest keyID);
/**
* Remember the key locator to use for a given key. Use
* this to publish this key in the future if not overridden by method
* calls. If no key locator stored for this key, and no override
* given, compute a KEY type key locator if this key has not been
* published, and the name given to it when published if it has.
* @param publisherKeyID the key whose locator to set; if null sets it for our
* default key
* @param keyLocator the new key locator for this key; overrides any previous value.
* If null, erases previous value and defaults will be used.
*/
public abstract void setKeyLocator(PublisherPublicKeyDigest publisherKeyID, KeyLocator keyLocator);
/**
* Get a KEY type key locator for a particular public key.
* @param publisherKeyID the key whose locator we want to retrieve
* @return the key locator
* @throws IOException
*/
public KeyLocator getKeyTypeKeyLocator(PublisherPublicKeyDigest publisherKeyID) {
PublicKey theKey = getPublicKey(publisherKeyID);
if (null == theKey) {
return null;
}
return new KeyLocator(theKey);
}
/**
* Get the public key associated with a given publisher
* @param publisher the digest of the desired key
* @return the key, or null if no such key known to our cache
* @throws IOException
*/
public abstract PublicKey getPublicKey(PublisherPublicKeyDigest publisher);
/**
* Get the publisher key digest associated with one of our signing keys
* @param signingKey key whose publisher data we want
* @return the digest of the corresponding public key
*/
public abstract PublisherPublicKeyDigest getPublisherKeyID(PrivateKey signingKey);
/**
* Get the private key associated with a given publisher
* @param publisherKeyID the public key digest of the desired key
* @return the key, or null if no such key known to our cache
*/
public abstract PrivateKey getSigningKey(PublisherPublicKeyDigest publisherKeyID);
/**
* Get all of our private keys, used for cache loading.
* @return an array of our currently available private keys
*/
public abstract PrivateKey[] getSigningKeys();
/**
* Get any timestamp associate with this key.
* @param keyID
* @return
*/
public abstract CCNTime getKeyVersion(PublisherPublicKeyDigest keyID);
/**
* Get the public key for a given publisher, going to the network to retrieve it if necessary.
* @param publisherKeyID the digest of the keys we want
* @param keyLocator the key locator to tell us where to retrieve the key from
* @param timeout how long to try to retrieve the key
* @return the key
* @throws IOException if we run into an error attempting to read the key
*/
public abstract PublicKey getPublicKey(
PublisherPublicKeyDigest publisherKeyID, KeyLocator keyLocator,
long timeout) throws IOException;
/**
* Get the public key for a given publisher, going to the network to retrieve it if necessary.
* Uses the SystemConfiguration.EXTRA_LONG_TIMEOUT to be aggressive and reexpress.
* @param publisherKeyID the digest of the keys we want
* @param keyLocator the key locator to tell us where to retrieve the key from
* @return the key
* @throws IOException if we run into an error attempting to read the key
*/
public PublicKey getPublicKey(
PublisherPublicKeyDigest publisherKeyID, KeyLocator keyLocator) throws IOException {
return getPublicKey(publisherKeyID, keyLocator, SystemConfiguration.EXTRA_LONG_TIMEOUT);
}
/**
* Get the public key for a given publisher as it was explicitly published,
* going to the network to retrieve it if necessary. If the key was not
* published as a KEY content item (was in our keystore, or was in a KEY
* type of key locator), this wil not retrieve anything.
* @param publisherKeyID the digest of the keys we want
* @param keyLocator the key locator to tell us where to retrieve the key from
* @param timeout how long to try to retrieve the key
* @return the key
* @throws IOException if we run into an error attempting to read the key
*/
public abstract PublicKeyObject getPublicKeyObject(
PublisherPublicKeyDigest desiredKeyID, KeyLocator locator, long timeout) throws IOException;
/**
* Allow subclasses to specialize key publication, if any.
* @param defaultPrefix our default namespace, if we know
* one for this environment. If null, take user defaults.
* @throws ConfigurationException
*/
public PublicKeyObject publishDefaultKey(ContentName keyName)
throws IOException, InvalidKeyException {
if (!initialized()) {
throw new IOException("KeyServer: cannot publish keys, have not yet initialized KeyManager!");
}
return publishKey(keyName, getDefaultKeyID(), null, null);
}
/**
* Publish a key at a certain name, signed by a specified identity (our
* default, if null). Usually used to
* publish our own keys, but can specify other keys we have in our cache.
*
* This publishes our key to our own internal key server, from where it can be retrieved
* as long as this KeyManager is running. It does not put it on the wire until someone
* requests it.
* Implementation Note: This code is used in CCNHandle initialization, and as such it
* cannot use a CCNHandle or any of the standard network operations without introducing
* a circular dependency. The code is very low-level and should only be modified with
* great caution.
*
* @param keyName content name of the public key
* @param keyToPublish public key digest of key to publish, if null publish our default key
* @param handle handle for ccn
* @throws IOException
* @throws InvalidKeyException
*/
public PublicKeyObject publishKey(ContentName keyName,
PublisherPublicKeyDigest keyToPublish,
PublisherPublicKeyDigest signingKeyID,
KeyLocator signingKeyLocator) throws InvalidKeyException, IOException {
if (null == keyToPublish) {
keyToPublish = getDefaultKeyID();
}
PublicKey theKey = getPublicKey(keyToPublish);
if (null == theKey) {
Log.warning("Cannot publish key {0} to name {1}, do not have public key in cache.", keyToPublish, keyName);
return null;
}
return publishKey(keyName, theKey, signingKeyID, signingKeyLocator, true);
}
/**
* Publish my public key to a local key server run in this JVM, as a self-signed key
* record. We do this by default if we don't have any credentials for this key; this
* just allows the caller to explicitly request this behavior even if we do have
* credentials.
* TODO need mechanism for controlling whether this ends up in the key locator...
* @param keyName content name of the public key
* @param keyToPublish public key digest of key to publish and to sign with
* @param handle handle for ccn
* @throws IOException
* @throws InvalidKeyException
*/
public PublicKeyObject publishSelfSignedKey(ContentName keyName,
PublisherPublicKeyDigest keyToPublish,
boolean learnKeyLocator) throws InvalidKeyException, IOException {
if (null == keyToPublish) {
keyToPublish = getDefaultKeyID();
}
PublicKey theKey = getPublicKey(keyToPublish);
if (null == theKey) {
Log.warning("Cannot publish key {0} to name {1}, do not have public key in cache.", keyToPublish, keyName);
return null;
}
return publishKey(keyName, theKey, keyToPublish, SELF_SIGNED_KEY_LOCATOR, learnKeyLocator);
}
/**
* Publish a key at a certain name, signed by our default identity. Usually used to
* publish our own keys, but can specify other keys we have in our cache.
*
* This publishes our key to our own internal key server, from where it can be retrieved
* as long as this KeyManager is running. It does not put it on the wire until someone
* requests it.
* Implementation Note: This code is used in CCNHandle initialization, and as such it
* cannot use a CCNHandle or any of the standard network operations without introducing
* a circular dependency. The code is very low-level and should only be modified with
* great caution.
*
* @param keyName the name under which the key should be published. For the moment, keys are
* unversioned.
* @param keyToPublish can be null, in which case we publish our own default public key
* @param signingKeyID key to sign with, if we wish to override default
* @param signingKeyLocator locator to use, if we wish to override default; if null, one will
* be computed
* @param learnKeyLocator do we remember the key locator used as the default for this signing key
* @throws InvalidKeyException
* @throws IOException
* @throws ConfigurationException
*/
public abstract PublicKeyObject publishKey(ContentName keyName,
PublicKey keyToPublish,
PublisherPublicKeyDigest signingKeyID,
KeyLocator signingKeyLocator,
boolean learnKeyLocator) throws InvalidKeyException, IOException;
/**
* Publish a key at a certain name, ensuring that it is stored in a repository. Will throw an
* exception if no repository available. Usually used to publish our own keys, but can specify
* any key known to our key cache.
* @param keyName Name under which to publish the key. Currently added under existing version, or version
* included in keyName.
* @param keyToPublish can be null, in which case we publish our own default public key.
* @param handle the handle to use for network requests
* @throws InvalidKeyException
* @throws IOException
*/
public abstract PublicKeyObject publishKeyToRepository(ContentName keyName,
PublisherPublicKeyDigest keyToPublish,
long timeToWaitForPreexisting)
throws InvalidKeyException, IOException;
/**
* Publish one of our keys to a repository, if it isn't already there, and ensure
* that it's self-signed regardless of what credentials we have for it (this
* is the default behavior if we have no credentials for the key. Throws an exception
* if no repository is available
* @param keyName Name under which to publish the key. Currently added under existing version, or version
* included in keyName.
* @param theKey the public key to publish, if we happen to have it; otherwise it will be retrieved
* from cache based on keyToPublish.
* @param keyToPublish can be null, in which case we publish our own default public key.
* @param handle the handle to use for network requests
* @throws InvalidKeyException
* @throws IOException
*/
public abstract PublicKeyObject publishSelfSignedKeyToRepository(ContentName keyName,
PublicKey theKey,
PublisherPublicKeyDigest keyToPublish,
long timeToWaitForPreexisting)
throws InvalidKeyException, IOException;
/**
* Publish our default key to a repository at its default location.
* @param handle the handle used for network requests
* @throws InvalidKeyException
* @throws IOException
*/
public PublicKeyObject publishKeyToRepository() throws InvalidKeyException, IOException {
return publishKeyToRepository(null, null);
}
public PublicKeyObject publishKeyToRepository(ContentName keyName, PublisherPublicKeyDigest keyToPublish)
throws InvalidKeyException, IOException {
return publishKeyToRepository(keyName, keyToPublish, SystemConfiguration.SHORT_TIMEOUT);
}
/**
* Publish a public key to repository, if it isn't already there.
* @param keyName content name of the public key to publish under (adds a version)
* @param keyToPublish the key to publish
* @param handle the handle to use to publish it with
* @return the published information about this key, whether we published it or someone else had
* @throws IOException
*/
public static PublicKeyObject publishKeyToRepository(
ContentName keyName,
PublicKey keyToPublish,
PublisherPublicKeyDigest signingKeyID,
KeyLocator signingKeyLocator,
CCNHandle handle) throws IOException {
return publishKeyToRepository(keyName, keyToPublish, signingKeyID, signingKeyLocator,
SystemConfiguration.SHORT_TIMEOUT, false, handle);
}
/**
* Publish a public key to repository, if it isn't already there.
* @param keyName content name of the public key to publish under (adds a version)
* @param keyToPublish the key to publish
* @param signingKeyID the key to sign with
* @param signingKeyLocator the key locator to use
* @param timeToWaitForPreexisting how long to wait to see if it has already been published
* (avoid re-publishing). If 0, we don't even try to find preexisting content.
* @param requirePublisherMatch check to see if we match the specified publisher. Key locator
* match too complex to check, make caller do that one.
* @param handle the handle to use to publish it with
* @return the published information about this key, whether we published it or someone else had
* @throws IOException
*/
public static PublicKeyObject publishKeyToRepository(
ContentName keyName,
PublicKey keyToPublish,
PublisherPublicKeyDigest signingKeyID,
KeyLocator signingKeyLocator,
long timeToWaitForPreexisting,
boolean requirePublisherMatch,
CCNHandle handle) throws IOException {
// To avoid repeating work, we first see if this content is available on the network, then
// if it's in a repository. That's because if it's not in a repository, we need to know if
// it's on the network, and this way we save doing that work twice (as the repo-checking code
// also needs to know if it's on the network).
PublisherPublicKeyDigest keyDigest = new PublisherPublicKeyDigest(keyToPublish);
// Returns immediately if timeToWaitForPreexisting is 0.
ContentObject availableContent =
CCNReader.isVersionedContentAvailable(keyName, ContentType.KEY, keyDigest.digest(),
(requirePublisherMatch ? signingKeyID : null), null, timeToWaitForPreexisting, handle);
// If we want it self-signed...
if ((SELF_SIGNED_KEY_LOCATOR == signingKeyLocator) && (null != availableContent)) {
// do mean == here....
// have already verified that keyDigest is the digest of the content of availableContent
if (!PublicKeyObject.isSelfSigned(SegmentationProfile.segmentRoot(availableContent.name()),
keyDigest, availableContent.signedInfo().getKeyLocator())) {
// it would be perfect, but it's not self-signed
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Found our key published under desired name {0}, but not self-signed as required - key locator is {1}.",
availableContent.name(), availableContent.signedInfo().getKeyLocator());
}
availableContent = null;
}
}
if (null != availableContent) {
// See if some repository has this key already
if (null != CCNReader.isContentInRepository(availableContent, timeToWaitForPreexisting, handle)) {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "publishKeyToRepository: key {0} is already in a repository; not re-publishing.", keyName);
}
} else {
// Otherwise, we just need to trick the repo into pulling it.
ContentName streamName = SegmentationProfile.segmentRoot(availableContent.name());
RepositoryFlowControl rfc = new RepositoryFlowControl(streamName, handle);
// This will throw an IOException if there is no repository there to read it.
rfc.startWrite(streamName, Shape.STREAM);
// OK, once we've emitted the interest, we don't actually need that flow controller anymore.
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Key {0} published to repository.", keyName);
}
rfc.close();
}
return new PublicKeyObject(availableContent, handle);
} else {
// We need to write this content ourselves, nobody else has it. We know we really want to
// write it, no point in checking again to see if it's there.
return publishKey(keyName, keyToPublish, signingKeyID, signingKeyLocator,
null, SaveType.REPOSITORY, handle, handle.keyManager());
}
}
/**
* Note: this is the lowest level interface to key publication; there are many higher-level
* interfaces that are probably what you want. This needs to be public to get across
* package constraints.
* Publish a signed record for this key. We've already decided we need to publish,
* and how; no more checks are made to see if the key already exists.
*
* @param keyName the key's content name. Will add a version when saving if it doesn't
* have one already. If it does have a version, will use that one (see below for effect
* of version on the key locator). (Note that this is not
* standard behavior for savable network content, which needs its version explicitly
* set.)
* @param keyToPublish the public key to publish
* @param keyID the publisher id
* @param signingKeyID the key id of the key pair to sign with
* @param signingKeyLocator the key locator to use if we save this key (if it is not already published).
* If not specified, we look for the default locator for the signing key. If there is none,
* and we are signing with the same key we are publishing, we build a
* self-referential key locator, using the name passed in (versioned or not).
* @param flowController flow controller to use. If non-null, saveType is ignored.
* @param saveType -- if we don't want to hand in a special-purpose flow controller, set saveType to RAW
* or REPO to get standard publishing behavior.
* @param handle the handle to use if we haven't specified a flow controller. Makes a flow controller
* of the type specified by saveType.
* @param keyManager the key manager to use to pull additional signing information (default keys
* and locators if not specified). If null, taken from handle. Also publish key added to its cache.
* @return the published information about this key, whether we published it or someone else had
* @throws IOException
*/
public static PublicKeyObject publishKey(
ContentName keyName, PublicKey keyToPublish,
PublisherPublicKeyDigest signingKeyID, KeyLocator signingKeyLocator,
CCNFlowControl flowController,
SaveType saveType,
CCNHandle handle,
KeyManager keyManager)
throws IOException {
if ((null == keyManager) && (null != handle)) {
keyManager = handle.keyManager();
}
if ((null == keyManager) || ((null == flowController) && (null == handle)) ||
((null == flowController) && (null == saveType))) {
// TODO DKS not quite right type...
throw new ErrorStateException("Must provide a flow controller or a handle and a save type, and a key manager!");
}
// Now, finally; it's not published, so make an object to write it
// with. We've already tried to pull it, so don't try here. Will
// set publisher info below.
// Need a key locator to stick in data entry for
// locator. Could use key itself, but then would have
// key both in the content for this item and in the
// key locator, which is redundant. Use naming form
// that allows for self-referential key names -- the
// CCN equivalent of a "self-signed cert". Means that
// we will refer to only the base key name and the publisher ID.
if (null == signingKeyID) {
signingKeyID = keyManager.getDefaultKeyID();
}
// Here is where we get tricky. We might really want the key to be of a particular
// version. In general, as we use the network objects to write versioned versioned stuff,
// we might not be able to take the last component of a name, if versioned, as the version
// to use to save -- might really want <name>/<version1>/<version2>. So unless we want to
// make that impossible to achieve, we need to not have the network objects take the
// name <name>/<version1> and save to <version1> (though they read from <version1> just
// fine given the same). You always want to save to a new version, unless someone tells you
// something different from the outside.
// Come up with a contorted option. If you want to publish <version>/<version> stuff, you
// need to pass in the second version...
CCNTime keyVersion = null; // do we force a version?
Tuple<ContentName, byte []> nameAndVersion = VersioningProfile.cutTerminalVersion(keyName);
if (null != nameAndVersion.second()) {
keyVersion = VersioningProfile.getVersionComponentAsTimestamp(nameAndVersion.second());
} else {
keyVersion = new CCNTime(); // so we can use it in locator
}
// Set key locator if not specified, include version for self-signed.
// Really do want == here
if ((null == signingKeyLocator) || (SELF_SIGNED_KEY_LOCATOR == signingKeyLocator)) {
KeyLocator existingLocator = keyManager.getKeyLocator(signingKeyID);
// If we've asked for this to be self-signed, or we have made the default KEY
// type key locator, make this a self-signed key.
if ((SELF_SIGNED_KEY_LOCATOR == signingKeyLocator) ||
(existingLocator.type() == KeyLocatorType.KEY)) {
PublisherPublicKeyDigest keyDigest = new PublisherPublicKeyDigest(keyToPublish);
if (signingKeyID.equals(keyDigest)) {
// Make a self-referential key locator. For now do not include the
// version.
existingLocator = new KeyLocator(
new KeyName(VersioningProfile.addVersion(keyName, keyVersion), signingKeyID));
if (Log.isLoggable(Log.FAC_KEYS, Level.FINER)) {
Log.finer(Log.FAC_KEYS, "Overriding constructed key locator of type KEY, making self-referential locator {0}", existingLocator);
}
}
}
signingKeyLocator = existingLocator;
}
PublicKeyObject keyObject = null;
if (null != flowController) {
// If a flow controller was specified, use that
keyObject = new PublicKeyObject(nameAndVersion.first(), keyToPublish,
signingKeyID, signingKeyLocator, flowController);
} else {
// No flow controller given, use specified saveType.
keyObject = new PublicKeyObject(nameAndVersion.first(), keyToPublish, saveType,
signingKeyID, signingKeyLocator, handle);
}
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "publishKey: key not previously published, making new key object {0} with version {1} displayed as {2}",
keyObject.getVersionedName(), keyVersion,
((null != nameAndVersion.second()) ? ContentName.componentPrintURI(nameAndVersion.second()) : "<no version>"));
}
// Eventually may want to find something already published and link to it, but be simple here.
if (!keyObject.save(keyVersion)) {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Not saving key when we thought we needed to: desired key value {0}, have key value {1}, " +
keyToPublish, new PublisherPublicKeyDigest(keyObject.publicKey()));
}
} else {
if (Log.isLoggable(Log.FAC_KEYS, Level.INFO)) {
Log.info(Log.FAC_KEYS, "Published key {0} to name {1} with key locator {2}.", keyToPublish, keyObject.getVersionedName(), signingKeyLocator);
}
}
keyManager.getPublicKeyCache().remember(keyObject);
return keyObject;
}
/**
* Right now KeyServers are hidden in our subclasses.... this makes it hard to expose
* control of filter registration. This is a bad attempt at an API for that, it should
* change. Don't make it abstract as subclasses may not need it.
* @throws IOException
*/
public void respondToKeyRequests(ContentName keyPrefix) throws IOException {}
/**
* Handle access control manager cache.
* @param contentName
* @return
*/
public abstract AccessControlManager getAccessControlManagerForName(ContentName contentName);
public abstract void rememberAccessControlManager(AccessControlManager acm);
}
| [
"[email protected]"
] | |
0bfd5e04ec8f2768e5e916b818abcf0a67f6ca25 | d37f5210cd4b5bef64df74a86919ae6a86ab0873 | /EstudoJavaComoProgramar/src/LivroNotas.java | 8e3f9834db5b28801b541fcd012ded4aa5af9d9f | [] | no_license | fabianoalv/CursoJava | 4434668ae330b1e084047ecafa4d77fb3bf89464 | da5644b66f9d45accdf1fffccfdba174648c637f | refs/heads/master | 2020-05-04T14:46:50.273152 | 2019-04-03T04:31:53 | 2019-04-03T04:31:53 | 179,210,402 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 1,919 | java |
public class LivroNotas {
private String nomeCurso;
private int[] notas;
public LivroNotas(String nomeCurso, int[] notas) {
this.nomeCurso = nomeCurso;
this.notas = notas;
}
public String getNomeCurso() {
return nomeCurso;
}
public void setNomeCurso(String nomeCurso) {
this.nomeCurso = nomeCurso;
}
// realiza várias operações nos dados
public void processarNotas() {
mostrarNotas();
System.out.printf("%nA média da classe é: %.2f%n", getMedia());
System.out.printf("Maior nota é %d%nMenor nota é: %d%n", getMaximo(), getMinimo());
barraGrafico();
}
public int getMinimo() {
int menorNota = notas[0];
for (int n : notas) {
if (n < menorNota)
menorNota = n;
}
return menorNota;
}
public int getMaximo() {
int maiorNota = notas[0];
for (int n : notas) {
if (n > maiorNota)
maiorNota = n;
}
return maiorNota;
}
public double getMedia() {
int total = 0;
for (int n : notas) {
total += n;
}
return (double) total / notas.length;
}
public void barraGrafico() {
System.out.println("Distribuíção de Notas: ");
//Armazena a frequencia de nota em cada intervalo de 10 notas
int[]frequencia = new int[11];
for (int n : notas) {
++frequencia[n/10];
}
//Gera a saída do rótulo de barras
for (int count = 0; count < frequencia.length; count++) {
if(count == 10)
System.out.printf("%5d: ", 100);
else
System.out.printf("%02d-%02d: ", count * 10, count * 10 + 9);
//Gera o gráfico com asteristico
for (int stars = 0; stars < frequencia[count]; stars++) {
System.out.print("*");
}
System.out.println();
}
}
public void mostrarNotas() {
System.out.printf("As notas são:%n%n");
for(int estudante = 0; estudante < notas.length; estudante++) {
System.out.printf("Estudante %2d: %3d%n", estudante + 1, notas[estudante]);
}
}
}
| [
"[email protected]"
] | |
59c5ccdde97018c0d5756603e2ece412661fe761 | a562d1095df3bab42da4ff54f56c8db94fe0c73f | /src/main/java/com/example/demo/exception/InstitutionNotFoundException.java | e899e98e53b22c11bbeed9e5caf4a409be090280 | [] | no_license | kangmin46/mission | e3ca6c9b62255b3f97bdd931d55d6287dc096d4e | 746aeda144f475ac69b1aa813a2b42bb885dd78f | refs/heads/master | 2020-11-23T21:46:15.991626 | 2019-12-15T14:59:44 | 2019-12-15T14:59:44 | 227,832,996 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 309 | java | package com.example.demo.exception;
public class InstitutionNotFoundException extends RuntimeException {
public static final String INSTITUTE_NOT_FOUND_MESSAGE = "해당 기관을 찾을 수 없습니다.";
public InstitutionNotFoundException() {
super(INSTITUTE_NOT_FOUND_MESSAGE);
}
}
| [
"[email protected]"
] | |
b95a4918ddce598451c22a5b1333d9916f36da0a | e274754a91532315366e69d67ebd4e622cf01383 | /src/Levels/Level.java | e91f47d2a13b86e4e5f840bfe368dfac40f64b80 | [] | no_license | ventz-lgtm/VEngine | 88b1dd687370ad2d33233c59466efcac971147f5 | 094bcaf908342de96316d303e3b607afc1622e08 | refs/heads/master | 2022-08-04T16:33:06.696235 | 2017-09-29T16:11:51 | 2017-09-29T16:11:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,019 | java | package Levels;
import java.awt.Color;
import java.util.ArrayList;
import Entities.Entity;
import Main.Game;
public abstract class Level {
private Game game;
private String name;
private Color background = new Color(30,30,30);
private boolean spawned = false;
private ArrayList<Entity> entities = new ArrayList<Entity>();
public Level(String name) {
this.name = name;
}
public void initialize(){
entities.clear();
onLoad();
}
public abstract void onLoad();
public void spawn() {
if(spawned) {return;}
spawned = true;
System.out.println("spawn level");
for(Entity e : entities) {
game.handler.createEntity(e);
}
}
public void setGame(Game game) {
this.game = game;
}
public Entity addEntity(Entity e) {
entities.add(e);
return e;
}
public String getName() {
return name;
}
public Game getGame() {
return game;
}
public void setBackgroundColor(Color background) {
this.background = background;
Game.frame.setBackgroundColor(background);;
}
}
| [
"[email protected]"
] | |
61d5b131422cc6dbee787c221bb377c6e7267241 | 6c9f684c2c7550ab436a949e8a9dd725ade7402e | /cims/src/dao/IShareFileDao.java | f7a1c7efd704f5be20e3cab6105368d4b9b63377 | [] | no_license | wenyoushixun/java- | 9fc73f45c32c4918d507eeb62205408e5ba185e3 | 55772433a8a59955496bc7c364f6e2663d7a4c94 | refs/heads/master | 2021-09-04T20:27:48.129433 | 2018-01-22T06:09:49 | 2018-01-22T06:09:49 | 112,140,132 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,007 | java | package dao;
import java.util.List;
import entity.ShareFile;
public interface IShareFileDao {
/**
* 保存一条共享文件记录
* @param file
* @throws Exception
*/
void saveShareFile(ShareFile file) throws Exception;
/**
* 删除共享文件记录
* @param file
* @throws Exception
*/
void deleteShareFile(ShareFile file) throws Exception;
/**
* 更新共享文件记录
* @param file
* @throws Exception
*/
void updateShareFile(ShareFile file) throws Exception;
/**
* 根据ID查找共享文件记录
* @param fildId
* @return
* @throws Exception
*/
ShareFile findShareFile(int fildId)throws Exception;
/**
* 查找所有共享文件
* @return
* @throws Exception
*/
List<ShareFile> findAllShareFiles()throws Exception;
/**
* 查找某人发布的所有共享文件
* @param sid
* @return
* @throws Exception
*/
List<ShareFile> findAllShareFiles(int sid)throws Exception;
}
| [
"[email protected]"
] | |
b0cd0cde0eb0689f982bdaf223221ac53a2263cf | 0ba903ad259e346fb880e78dcca23660be0dce4b | /wfe-web/src/main/java/ru/runa/common/web/portlet/impl/ReturnHomeExceptionHandler.java | 8bdc492f94de1418831f8908c0f30fbef3078186 | [] | no_license | ARyaskov/runawfe-server | c61eaff10945c99a8dab423c55faa1b5b6159e1d | f721a7613da95b9dd3ac2bf5a86d3cac7bca683e | refs/heads/master | 2021-05-03T06:09:36.209627 | 2017-02-06T13:19:47 | 2017-02-06T13:19:47 | 70,156,281 | 0 | 0 | null | 2016-10-06T13:25:41 | 2016-10-06T13:25:41 | null | UTF-8 | Java | false | false | 2,223 | java | /*
* This file is part of the RUNA WFE project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; version 2.1
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
package ru.runa.common.web.portlet.impl;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessages;
import ru.runa.common.web.ActionExceptionHelper;
import ru.runa.common.web.portlet.PortletExceptionHandler;
public class ReturnHomeExceptionHandler implements PortletExceptionHandler {
@Override
public boolean processError(Exception exception, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
ActionExceptionHelper.addException(getActionErrors(request), exception);
String thinInterfacePage = (String) request.getAttribute("runawfe.thin.interface.page");
if (thinInterfacePage == null) {
thinInterfacePage = "/start.do";
}
servletContext.getRequestDispatcher(thinInterfacePage).forward(request, response);
return true;
}
private static ActionMessages getActionErrors(HttpServletRequest request) {
ActionMessages messages = (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
if (messages == null) {
messages = new ActionMessages();
request.setAttribute(Globals.ERROR_KEY, messages);
}
return messages;
}
}
| [
"[email protected]"
] | |
ae1c1a9e500a03b430893febc1696afc4f09bfc6 | 5a849f62327bb8e4958925813ae398b9fb9d95e8 | /src/main/java/com/diplomski/bioskop/model/Ocena.java | 6aa33d760df34e3af452d56dc9109ee22345347d | [] | no_license | MiloradSegan/Cinema | 43a12e48727fb275e540e7ecf684ff0f0b3a2a32 | 65b046bd738c11c2e8b663d125d60d426a5af078 | refs/heads/master | 2020-07-03T22:41:03.444898 | 2019-08-13T07:27:15 | 2019-08-13T07:27:15 | 202,010,486 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,061 | java | package com.diplomski.bioskop.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name="ocene")
public class Ocena {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private double ocena;
@ManyToOne
@JoinColumn(name="idfilma")
private Film film;
@ManyToOne
@JoinColumn(name="korsnikId")
private Korisnik korisnik;
public Ocena() {
super();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getOcena() {
return ocena;
}
public void setOcena(double ocena) {
this.ocena = ocena;
}
public Film getFilm() {
return film;
}
public void setFilm(Film film) {
this.film = film;
}
public Korisnik getKorisnik() {
return korisnik;
}
public void setKorisnik(Korisnik korisnik) {
this.korisnik = korisnik;
}
}
| [
"[email protected]"
] | |
a5b0949e792b0840e004fdc5e890caf282795b2f | 3fa72fe5e9366d6c79b438811d8625bd354aa36d | /pyramus/src/main/java/fi/pyramus/util/dataimport/DataImportUtils.java | 8d0bc05a96a04f43beb0b21c1422c8b69af54579 | [] | no_license | myrtti/pyramus | 4f486d90c109b898a3a1a53c8c9b354a182066f1 | b95ce66441925c94d13168f3842993eb7a61e8fe | refs/heads/master | 2021-01-09T06:58:56.067323 | 2014-02-18T07:23:48 | 2014-02-18T07:23:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,170 | java | package fi.pyramus.util.dataimport;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.commons.lang.math.NumberUtils;
import fi.internetix.smvc.SmvcRuntimeException;
import fi.pyramus.domainmodel.base.VariableType;
import fi.pyramus.domainmodel.projects.ProjectModuleOptionality;
import fi.pyramus.domainmodel.students.Sex;
import fi.pyramus.domainmodel.students.StudentContactLogEntryType;
import fi.pyramus.domainmodel.users.Role;
import fi.pyramus.framework.PyramusStatusCode;
import fi.pyramus.framework.UserRole;
import fi.pyramus.persistence.usertypes.MonetaryAmount;
public class DataImportUtils {
/**
*
* @param pojo
* @param methodName
* @param params
* @return
*/
public static Method getMethod(Object pojo, String methodName, Class<?>[] params) {
Method method = null;
Class<?> cClass = pojo.getClass();
while (cClass != null && method == null) {
try {
method = cClass.getDeclaredMethod(methodName, params);
} catch (NoSuchMethodException nsf) {
cClass = cClass.getSuperclass();
}
}
return method;
}
/**
*
* @param pojo
* @param property
* @param value
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public static void setValue(Object pojo, String property, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Field field = getField(pojo, property);
Class<?> fieldType = field.getType();
ValueInterpreter<?> valueInterpreter = DataImportUtils.getValueInterpreter(fieldType);
if (valueInterpreter != null)
setFieldValue(pojo, field, valueInterpreter.interpret(value));
else
throw new SmvcRuntimeException(PyramusStatusCode.UNDEFINED, "Value interpreter for " + fieldType + " is not implemented yet");
}
/**
*
* @param pojo
* @param property
* @return
*/
public static Field getField(Object pojo, String property) {
Field field = null;
Class<?> cClass = pojo.getClass();
while (cClass != null && field == null) {
try {
field = cClass.getDeclaredField(property);
} catch (NoSuchFieldException nsf) {
cClass = cClass.getSuperclass();
}
}
return field;
}
/**
*
* @param pojo
* @param field
* @param value
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public static void setFieldValue(Object pojo, Field field, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException {
field.setAccessible(true);
field.set(pojo, value);
}
/**
* Returns Value Interpreter for given type
*
* @param fieldType
* @return
*/
public static ValueInterpreter<?> getValueInterpreter(Class<?> fieldType) {
return interpreters.get(fieldType);
}
private static Map<Class<?>, ValueInterpreter<?>> interpreters = new HashMap<Class<?>, ValueInterpreter<?>>();
static {
interpreters.put(String.class, new ValueInterpreter<String>() {
public String interpret(Object o) {
return (String) o;
}
});
interpreters.put(Long.class, new ValueInterpreter<Long>() {
public Long interpret(Object o) {
return NumberUtils.createLong((String) o);
}
});
interpreters.put(Double.class, new ValueInterpreter<Double>() {
public Double interpret(Object o) {
return NumberUtils.createDouble((String) o);
}
});
interpreters.put(Boolean.class, new ValueInterpreter<Boolean>() {
public Boolean interpret(Object o) {
return "true".equals(o) ? Boolean.TRUE : Boolean.FALSE;
}
});
interpreters.put(Date.class, new ValueInterpreter<Date>() {
public Date interpret(Object o) {
if ("NOW".equals(o))
return new Date(System.currentTimeMillis());
String s = (String) o;
if (s.contains("-")) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try {
return df.parse(s);
} catch (ParseException e) {
e.printStackTrace();
throw new SmvcRuntimeException(e);
}
}
if (s.contains(".")) {
DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
try {
return df.parse(s);
} catch (ParseException e) {
e.printStackTrace();
throw new SmvcRuntimeException(e);
}
}
return new Date(NumberUtils.createLong(s));
}
});
interpreters.put(UserRole.class, new ValueInterpreter<UserRole>() {
public UserRole interpret(Object o) {
return UserRole.getRole(NumberUtils.createInteger((String) o));
}
});
interpreters.put(Role.class, new ValueInterpreter<Role>() {
public Role interpret(Object o) {
return Role.getRole(NumberUtils.createInteger((String) o));
}
});
interpreters.put(MonetaryAmount.class, new ValueInterpreter<MonetaryAmount>() {
public MonetaryAmount interpret(Object o) {
return new MonetaryAmount(NumberUtils.createDouble((String) o));
}
});
interpreters.put(Sex.class, new ValueInterpreter<Sex>() {
public Sex interpret(Object o) {
return "male".equalsIgnoreCase((String) o) ? Sex.MALE : Sex.FEMALE;
}
});
interpreters.put(ProjectModuleOptionality.class, new ValueInterpreter<ProjectModuleOptionality>() {
public ProjectModuleOptionality interpret(Object o) {
return ProjectModuleOptionality.getOptionality(NumberUtils.createInteger((String) o));
}
});
interpreters.put(VariableType.class, new ValueInterpreter<VariableType>() {
public VariableType interpret(Object o) {
return VariableType.getType(NumberUtils.createInteger((String) o));
}
});
interpreters.put(StudentContactLogEntryType.class, new ValueInterpreter<StudentContactLogEntryType>() {
public StudentContactLogEntryType interpret(Object o) {
return StudentContactLogEntryType.getType(NumberUtils.createInteger((String) o));
}
});
interpreters.put(Locale.class, new ValueInterpreter<Locale>() {
public Locale interpret(Object o) {
return new Locale((String) o);
}
});
interpreters.put(Integer.class, new ValueInterpreter<Integer>() {
public Integer interpret(Object o) {
return NumberUtils.createInteger((String) o);
}
});
}
}
| [
"[email protected]"
] | |
3d4067a947503c6c4a1571585c8a4c19d70688b0 | 6fd908523412b376e6f1f2d32a1b3d63e8f936a9 | /src/main/java/com/hatanaka/ecommerce/payment/entity/PaymentEntity.java | abf0639bde2f4d03550f3980ee4d602e2ee6aa77 | [] | no_license | schott-anderson/dio-ecommerce-payment | 7cd3a39a47c6614c96767aa5d3f92df000c77981 | b1cb6f97580ef9069f1814a3a788af942f2b7191 | refs/heads/main | 2023-08-17T08:45:23.329702 | 2021-09-23T15:44:01 | 2021-09-23T15:44:01 | 408,993,571 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 846 | java | package com.hatanaka.ecommerce.payment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.envers.Audited;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
@Audited
@EntityListeners(AuditingEntityListener.class)
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PaymentEntity {
@Id
@GeneratedValue
private Long id;
@Column
private String code;
@Column
private String checkoutCode;
@CreatedDate
private LocalDateTime createdAt;
@LastModifiedDate
private LocalDateTime updatedAt;
} | [
"[email protected]"
] | |
c520d6b8cd7865d1e9d2f8afbe4143d20ad54bc6 | 6a4a1c5835f6a575a5b00b3db3ed328019a93581 | /app/src/main/java/com/example/david/journalapp/data/source/local/LocalDb.java | 901e6c0d8515d099ab4ad818aeef5eb4c2df617c | [
"MIT"
] | permissive | davidkathoh/JournalApp | 96692ca51931776dfcd0f34359bad5127ca6d461 | f7eb00d82c9583c8a0e44d55e84195426b5ffea3 | refs/heads/master | 2020-03-21T12:59:48.420007 | 2019-02-01T13:50:16 | 2019-02-01T13:50:16 | 138,582,379 | 2 | 1 | null | 2018-08-25T14:27:55 | 2018-06-25T10:54:33 | Java | UTF-8 | Java | false | false | 907 | java | package com.example.david.journalapp.data.source.local;
import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;
import com.example.david.journalapp.data.Note;
/**
* Created by david on 6/27/18.
*/
@Database(entities = Note.class,version = 1)
public abstract class LocalDb extends RoomDatabase{
private static LocalDb INSTANCE;
public abstract NoteDao mNoteDaoDao();
public static LocalDb getLocalDb(Context context) {
if (INSTANCE == null){
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
LocalDb.class,"Note")
.fallbackToDestructiveMigration()
.build();
}
return INSTANCE;
}
public static void destroyInstance() {
INSTANCE = null;
}
}
| [
"[email protected]"
] | |
5df516a30a141ca6928d682f11747ef27c591654 | 486f84c1b4432948e63de3fd9d74eec9b45e6c67 | /snsbuy~huiduweb/biz/src/main/java/net/java/mapyou/mybatis/enums/NotifyType.java | 676f0e786f34e4bf15e08da1e6b141cbaff4419d | [] | no_license | gubaojian/huidu | 78a49eaf59d2605485a9cc970de531c96e8cb756 | 7d2fe0d83304cffab8b71c8aad125103ff403349 | refs/heads/master | 2022-12-25T14:07:49.886961 | 2020-06-06T09:45:14 | 2022-01-05T01:37:39 | 188,653,887 | 1 | 1 | null | 2022-12-16T10:04:48 | 2019-05-26T07:39:34 | Java | UTF-8 | Java | false | false | 661 | java | package net.java.mapyou.mybatis.enums;
public enum NotifyType {
NONE((byte)0, "无任何提示"),
BRADGE((byte)1, "红点提示"),
PUSH((byte)2, "Push消息提示");
private final byte value;
private final String desc;
private NotifyType(byte value, String desc){
this.value = value;
this.desc = desc;
}
public byte getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static NotifyType type(Byte value){
if(value == null){
return NONE;
}
NotifyType[] values = NotifyType.values();
for(NotifyType os : values){
if (os.getValue() == value) {
return os;
}
}
return NONE;
}
}
| [
"[email protected]"
] | |
6e424894eb787a5b8dabc78748ff9e956b777441 | 8b9facbaf9c57ee998aba63d57b14d93a5d95b8e | /src/org/xpande/financial/model/MZMedioPagoMotivoRep.java | 8798b623e04e0ecafd3acbfee981ba515bc36604 | [] | no_license | gvilauy/XpandeFinancial | e5270094176d43da3017e7213ef75d634426627a | 4a69c6203b54d685af686be630b18b7d79378cd9 | refs/heads/master | 2023-06-30T07:32:45.286633 | 2023-06-15T12:07:47 | 2023-06-15T12:07:47 | 98,096,052 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 638 | java | package org.xpande.financial.model;
import java.sql.ResultSet;
import java.util.Properties;
/**
* Modelo para motivos de reemplazo de medios de pago.
* Product: Adempiere ERP & CRM Smart Business Solution. Localization : Uruguay - Xpande
* Xpande. Created by Gabriel Vila on 9/21/17.
*/
public class MZMedioPagoMotivoRep extends X_Z_MedioPagoMotivoRep {
public MZMedioPagoMotivoRep(Properties ctx, int Z_MedioPagoMotivoRep_ID, String trxName) {
super(ctx, Z_MedioPagoMotivoRep_ID, trxName);
}
public MZMedioPagoMotivoRep(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
}
}
| [
"[email protected]"
] | |
035fc47ce15f71610fb7171fbd519ba6241724f6 | 3fd59375ae82528ee9c6ac2e09438f5ae1b83eb0 | /app/src/main/java/com/example/oluwatobiloba/medmanager/database/MedicationDao.java | 6cf70abc88fb857f25a5719b482200ee2bc8ca85 | [] | no_license | natintosh/Med-Manager | e11ce76e464f29fc3943dd59f9bf94b06dbf1fcc | 35ab2f62cdff4c423381b6358d1a361184c4c540 | refs/heads/master | 2020-03-11T12:42:42.675109 | 2018-04-18T18:54:12 | 2018-04-18T18:54:12 | 130,005,006 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,241 | java | package com.example.oluwatobiloba.medmanager.database;
import android.arch.lifecycle.LiveData;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import com.example.oluwatobiloba.medmanager.models.Medication;
import java.util.List;
@Dao
public interface MedicationDao {
@Query("SELECT * FROM medication")
LiveData<List<Medication>> getAll();
@Query("SELECT * FROM medication")
List<Medication> getAllMedication();
@Query("SELECT * FROM medication WHERE medicationId IN (:medicationIds)")
List<Medication> loadAllByIds(int[] medicationIds);
@Query("SELECT * FROM medication WHERE medicationId = :medicationId LIMIT 1")
Medication loadById(long medicationId);
@Query("SELECT * FROM medication WHERE name LIKE :name LIMIT 1")
Medication findByName(String name);
@Query("SELECT * FROM medication ORDER BY start_date ASC")
List<Medication> sortMedicationByStartDate();
@Insert
long insertMedication(Medication medication);
@Insert
void insertMultipleMedications(Medication... medications);
@Delete
void delete(Medication medication);
}
| [
"[email protected]"
] | |
2826d8e76de8d4030b1912d33fb3035b69aa543e | 7b0de570be092879a621d47ccfbd07525d79dcb1 | /datacatalog-dashboard/src/main/java/edu/indiana/d2i/datacatalog/dashboard/api/PerformanceLog.java | 41dc9d40d9b7bca88eedc4b41e4745f5684bd126 | [] | no_license | milinda/DataCatalog-Dashboard | d31f89ed47885d0cede27e9f72e1b5424e6d3aea | 932f930bf8597fb973312c8c6a59b205f1db45df | refs/heads/master | 2021-01-20T06:25:57.166409 | 2011-11-24T18:19:35 | 2011-11-24T18:19:35 | 2,551,077 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,068 | java | package edu.indiana.d2i.datacatalog.dashboard.api;
import edu.indiana.d2i.datacatalog.dashboard.Constants;
import edu.indiana.d2i.datacatalog.dashboard.api.beans.Collections;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@Path("/perflog")
public class PerformanceLog {
private static Log log = LogFactory.getLog(PerformanceLog.class);
@Context
ServletContext context;
@GET
@Path("currentstate")
@Produces(MediaType.TEXT_PLAIN)
public String getCurrentState() throws IOException {
String dashboardConfFilePath = context.getRealPath("/WEB-INF/conf/dashboard-conf.properties");
Properties dashboardProps = new Properties();
dashboardProps.load(new FileInputStream(new File(dashboardConfFilePath)));
if (dashboardProps.get(Constants.PROP_DATACAT_PERF_LOG) != null) {
String tail = tail(new File(((String) dashboardProps.get(Constants.PROP_DATACAT_PERF_LOG)).trim()));
if (tail != null) {
String[] tailElements = tail.split("\\|");
return "In the " + tailElements[1] + " queue, processing data product " + tailElements[4] +
" of catalog " + tailElements[3];
}
return "Error reading performance log.";
}
return "Cannot find performance log file in configuration.";
}
@GET
@Path("history")
@Produces(MediaType.APPLICATION_JSON)
public String getDataCrawlingHistory() throws IOException {
JSONObject crawlHistory = new JSONObject();
crawlHistory.put("dateTimeFormat", "Gregorian");
org.json.simple.JSONArray events = new JSONArray();
String dashboardConfFilePath = context.getRealPath("/WEB-INF/conf/dashboard-conf.properties");
Properties dashboardProps = new Properties();
dashboardProps.load(new FileInputStream(new File(dashboardConfFilePath)));
if (dashboardProps.get(Constants.PROP_DATACAT_PERF_LOG) != null) {
//String tail = tail2(new File(((String) dashboardProps.get(Constants.PROP_DATACAT_PERF_LOG)).trim()), 2);
List<String> eventStrings = getCatalogerEvents();
if (eventStrings != null && eventStrings.size() > 0) {
for (String element : eventStrings) {
String[] items = element.split("\\|");
events.add(createEvent(items[0], "Done processing catalog: " + items[3]));
}
crawlHistory.put("events", events);
return crawlHistory.toJSONString();
}
return "{'error': 'Error reading performance log.'}";
}
return "{'error': 'Cannot find performance log file in configuration.'}";
}
private JSONObject createEvent(String date, String title) {
JSONObject event = new JSONObject();
event.put("start", date);
event.put("title", title);
event.put("durationEvent", false);
return event;
}
public String tail(File file) {
try {
RandomAccessFile fileHandler = new RandomAccessFile(file, "r");
long fileLength = file.length() - 1;
StringBuilder sb = new StringBuilder();
for (long filePointer = fileLength; filePointer != -1; filePointer--) {
fileHandler.seek(filePointer);
int readByte = fileHandler.readByte();
if (readByte == 0xA) {
if (filePointer == fileLength) {
continue;
} else {
break;
}
} else if (readByte == 0xD) {
if (filePointer == fileLength - 1) {
continue;
} else {
break;
}
}
sb.append((char) readByte);
}
return sb.reverse().toString();
} catch (java.io.FileNotFoundException e) {
log.error("Log file not found.", e);
return null;
} catch (java.io.IOException e) {
log.error("Error reading log file.", e);
return null;
}
}
public String tail2(File file, int lines) {
try {
java.io.RandomAccessFile fileHandler = new java.io.RandomAccessFile(file, "r");
long fileLength = file.length() - 1;
StringBuilder sb = new StringBuilder();
int line = 0;
for (long filePointer = fileLength; filePointer != -1; filePointer--) {
fileHandler.seek(filePointer);
int readByte = fileHandler.readByte();
if (readByte == 0xA) {
if (line == lines) {
if (filePointer == fileLength) {
continue;
} else {
break;
}
}
} else if (readByte == 0xD) {
line = line + 1;
if (line == lines) {
if (filePointer == fileLength - 1) {
continue;
} else {
break;
}
}
}
sb.append((char) readByte);
}
sb.deleteCharAt(sb.length() - 1);
String lastLine = sb.reverse().toString();
return lastLine;
} catch (java.io.FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (java.io.IOException e) {
e.printStackTrace();
return null;
}
}
public void tail3(File src, OutputStream out, int maxLines) throws FileNotFoundException, IOException {
BufferedReader reader = new BufferedReader(new FileReader(src));
String[] lines = new String[maxLines];
int lastNdx = 0;
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
if (lastNdx == lines.length) {
lastNdx = 0;
}
lines[lastNdx++] = line;
}
OutputStreamWriter writer = new OutputStreamWriter(out);
for (int ndx = lastNdx; ndx != lastNdx - 1; ndx++) {
if (ndx == lines.length) {
ndx = 0;
}
writer.write(lines[ndx]);
writer.write("\n");
}
writer.flush();
}
private List<String> getCatalogerEvents() throws IOException {
String dashboardConfFilePath = context.getRealPath("/WEB-INF/conf/dashboard-conf.properties");
Properties dashboardProps = new Properties();
dashboardProps.load(new FileInputStream(new File(dashboardConfFilePath)));
if (dashboardProps.get(Constants.PROP_DATACAT_PERF_LOG) != null) {
Runtime r = Runtime.getRuntime();
try {
/*
* Here we are executing the UNIX command ls for directory listing.
* The format returned is the long format which includes file
* information and permissions.
*/
Process p = r.exec("grep Cataloger " + dashboardProps.get(Constants.PROP_DATACAT_PERF_LOG));
InputStream in = p.getInputStream();
BufferedInputStream buf = new BufferedInputStream(in);
InputStreamReader inread = new InputStreamReader(buf);
BufferedReader bufferedreader = new BufferedReader(inread);
// Read the ls output
List<String> matchingEvents = new ArrayList<String>();
String line;
while ((line = bufferedreader.readLine()) != null) {
matchingEvents.add(line);
}
// Check for ls failure
try {
if (p.waitFor() != 0) {
log.info("exit value = " + p.exitValue());
}
} catch (InterruptedException e) {
log.error("Error executing grep on performance.log!",e);
} finally {
// Close the InputStream
bufferedreader.close();
inread.close();
buf.close();
in.close();
}
return matchingEvents;
} catch (IOException e) {
log.error("Error executing grep on performance log!", e);
}
}
return java.util.Collections.emptyList();
}
}
| [
"[email protected]"
] | |
4a29e2e211c96637ac5734b4debe26af4219ec44 | b37e12dc57857d57c926061f3cc98a8c4e4a9221 | /src/mitiv/linalg/ScaleOperator.java | ca263fcc746fd9300a50af9956ce61b4b6005ec7 | [
"MIT"
] | permissive | emmt/TiPi | 7e45f5fecd0a0d4ea36c6fd64e400a03b2fb97a9 | dfcdf5b21eeaaf6b9d0372cb86f527ff47ba3dfd | refs/heads/master | 2020-12-25T17:17:45.290688 | 2020-11-03T22:00:01 | 2020-11-03T22:00:23 | 19,735,125 | 8 | 3 | null | 2014-05-14T09:25:18 | 2014-05-13T10:39:13 | null | UTF-8 | Java | false | false | 2,811 | java | /*
* This file is part of TiPi (a Toolkit for Inverse Problems and Imaging)
* developed by the MitiV project.
*
* Copyright (c) 2014-2016 the MiTiV project, http://mitiv.univ-lyon1.fr/
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package mitiv.linalg;
import mitiv.exception.SingularOperatorException;
public class ScaleOperator extends LinearEndomorphism {
protected double scale = 1.0;
/**
* Create a new scale operator which operates on a given vector space.
*
* The returned operator has a scaling factor equal to 1 and is thus
* similar to the identity.
* @param vsp
* the vector space.
*/
public ScaleOperator(VectorSpace vsp) {
super(vsp);
}
/**
* Create a new scale operator which operates on a given vector space.
*
* @param vsp
* the vector space.
* @param alpha
* the scaling factor.
*/
public ScaleOperator(VectorSpace vsp, double alpha) {
super(vsp);
this.scale = alpha;
}
@Override
protected void _apply(Vector dst, final Vector src, int job) {
if (job == DIRECT || job == ADJOINT) {
space._scale(dst, scale, src);
} else if (scale != 0.0) {
space._scale(dst, 1.0/scale, src);
} else {
throw new SingularOperatorException();
}
}
/**
* Get the scaling factor of a scale operator.
* @return the scaling factor of the operator.
*/
public double getScale() {
return scale;
}
/**
* Set the scaling factor of a scale operator.
* @param alpha
* the new scaling factor.
*/
public void setScale(double alpha) {
this.scale = alpha;
}
}
| [
"[email protected]"
] | |
73393cb6caa5f6db0c42d6d23c83b492ae0df8cd | 36ff4a05af289437faf2fe21ea6f2055cc8e576f | /timesPayMobile/android/app/src/main/java/com/timespaymobile/generated/BasePackageList.java | b055d8c8c1408103cdda16b4d7739391bf20eaed | [] | no_license | siusiukim/Times-Pay | e78f59579e120a2ca7a77aa1302a8d977df70a78 | da3bc76b7fc97e01008f96e3ceb22fba9719db1e | refs/heads/master | 2020-12-04T00:04:32.838461 | 2020-01-02T18:07:22 | 2020-01-02T18:07:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 485 | java | package com.timespaymobile.generated;
import java.util.Arrays;
import java.util.List;
import org.unimodules.core.interfaces.Package;
public class BasePackageList {
public List<Package> getPackageList() {
return Arrays.<Package>asList(
new expo.modules.constants.ConstantsPackage(),
new expo.modules.filesystem.FileSystemPackage(),
new expo.modules.permissions.PermissionsPackage(),
new expo.modules.securestore.SecureStorePackage()
);
}
}
| [
"[email protected]"
] | |
d6a796f71323c4958f838ecdc9ee2f20a501ca62 | 6ee92ecc85ba29f13769329bc5a90acea6ef594f | /bizcore/WEB-INF/retailscm_core_src/com/doublechaintech/retailscm/provincecenteremployee/CandidateProvinceCenterEmployee.java | 3aca5e681f774f5aca81c2a1972afe855c56600d | [] | no_license | doublechaintech/scm-biz-suite | b82628bdf182630bca20ce50277c41f4a60e7a08 | 52db94d58b9bd52230a948e4692525ac78b047c7 | refs/heads/master | 2023-08-16T12:16:26.133012 | 2023-05-26T03:20:08 | 2023-05-26T03:20:08 | 162,171,043 | 1,387 | 500 | null | 2023-07-08T00:08:42 | 2018-12-17T18:07:12 | Java | UTF-8 | Java | false | false | 222 | java | package com.doublechaintech.retailscm.provincecenteremployee;
import com.doublechaintech.retailscm.BaseCandidateEntity;
public class CandidateProvinceCenterEmployee extends BaseCandidateEntity<ProvinceCenterEmployee> {}
| [
"[email protected]"
] | |
cdaf6a6f21abf1db430b49e2142276e8d9e8e207 | ed70f3b7189afd587fe9a9ecbdf49b6cb2bea43a | /A295_FindMedianFromDataStream.java | 5bca0f491a9cb308b0b5da0006643e09c1671354 | [] | no_license | wfei26/LeetCode-Java | 9fb25a3f5a8377469a74b2945ecbd4114e57e860 | ed710da888d25e3d67342c16d957423c8e06873f | refs/heads/master | 2020-03-28T15:21:57.599960 | 2019-04-23T01:09:31 | 2019-04-23T01:09:31 | 148,585,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,644 | java | import java.util.Collections;
import java.util.PriorityQueue;
public class A295_FindMedianFromDataStream {
public static void main(String[] args) {
A295_FindMedianFromDataStream solution = new A295_FindMedianFromDataStream();
solution.addNum(1);
solution.addNum(2);
System.out.println(solution.findMedian());
solution.addNum(3);
System.out.println(solution.findMedian());
}
//left part - max heap
PriorityQueue<Integer> maxHeap;
//right part - min heap
PriorityQueue<Integer> minHeap;
/** initialize your data structure here. */
public A295_FindMedianFromDataStream() {
maxHeap = new PriorityQueue<>(Collections.reverseOrder());
minHeap = new PriorityQueue<>();
}
/** AddNum() strategy: divides the entire “array" into two parts and saves in two priority queues max heap and min
* heap. Every new element will be inserted into the max heap, and then (after heapify) move the root of max heap
* to to the min heap. Always keep balance (maxHeap.size() >= minHeap.size()) of two sides after insertion step. */
public void addNum(int num) {
maxHeap.offer(num);
minHeap.offer(maxHeap.poll());
// keep size of minHeap is always smaller than or equal to max heap
if (minHeap.size() > maxHeap.size()) {
maxHeap.offer(minHeap.poll());
}
}
public double findMedian() {
if (maxHeap.size() > minHeap.size()) {
return (double)maxHeap.peek();
}
else {
return (double)(maxHeap.peek() + minHeap.peek()) / 2;
}
}
}
| [
"[email protected]"
] | |
e346888a4bbfacae7224ef802ace498d0685a90a | 84671b8d8fa5bc51be717d579e2b50de6dbae957 | /app/src/main/java/com/example/xavi/shoppinglist3/ShoppingList3Activity.java | b8830545b868f987560771bdf10839de9f55caca | [] | no_license | XaviVilaseca/ShoppingList3 | eb6769b1d5668bd80be23b0994a02c760f4da5ad | 19459cccd59cbc5e04a68251be78a0b1b536698e | refs/heads/master | 2021-07-18T20:59:21.126332 | 2017-10-27T18:43:23 | 2017-10-27T18:43:23 | 108,582,224 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,191 | java | package com.example.xavi.shoppinglist3;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.RequiresPermission;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
public class ShoppingList3Activity extends AppCompatActivity {
private static final String FILENAME = "shopping_list.txt";
private static final int MAX_BYTES = 8000;
private ArrayList<ShoppingItem> itemlist;
private ShoppingListAdapter adapter;
private ListView list;
private Button addButton;
private EditText editItem;
private void WriteItemList() {
try {
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
for (int i = 0; i < itemlist.size(); i++) {
ShoppingItem it = itemlist.get(i);
String line = String.format("%s;%b\n", it.getText(), it.isCheck());
fos.write(line.getBytes());
}
fos.close();
} catch (FileNotFoundException e) {
Log.e("xavi", "writeItemList: FileNotFoundException");
Toast.makeText(this, R.string.cannot_write, Toast.LENGTH_LONG).show();
} catch (IOException e) {
Log.e("xavi", "writeItemList: IOException");
Toast.makeText(this, R.string.cannot_write, Toast.LENGTH_LONG).show();
}
}
private void ReadItemList() {
itemlist = new ArrayList<>();
try {
FileInputStream fis = openFileInput(FILENAME);
byte[] buffer = new byte[MAX_BYTES];
int nread = fis.read(buffer);
if (nread > 0){
String content = new String(buffer, 0, nread);
String[] lines = content.split("\n");
for (String line : lines) {
String[] parts = line.split(";");
itemlist.add(new ShoppingItem(parts[0], parts[1].equals("true")));
}
}
fis.close();
} catch (FileNotFoundException e) {
Log.e("xavi", "ReadItemList: FileNotFoundException");
} catch (IOException e) {
Log.e("xavi", "ReadItemList: IOException");
Toast.makeText(this, R.string.cannot_read, Toast.LENGTH_LONG).show();
}
}
@Override
protected void onStop() {
super.onStop();
WriteItemList();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shopping_list3);
list = (ListView) findViewById(R.id.list);
addButton = (Button) findViewById(R.id.button_add);
editItem = (EditText) findViewById(R.id.editItem);
itemlist = new ArrayList<>();
ReadItemList();
adapter = new ShoppingListAdapter(this, android.R.layout.simple_list_item_1, itemlist);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addItem();
}
});
editItem.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
addItem();
return false;
}
});
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
itemlist.get(pos).toggleCheck();
adapter.notifyDataSetChanged();
}
});
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> list, View item, int pos, long id) {
maybeRemobeItem(pos);
return false;
}
});
list.setAdapter(adapter);
}
private void maybeRemobeItem(final int pos) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.confirm);
String fmt = getResources().getString(R.string.confirm_message);
builder.setMessage(String.format(fmt, itemlist.get(pos).getText()));
builder.setPositiveButton(R.string.remove, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
itemlist.remove(pos);
adapter.notifyDataSetChanged();
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.create().show();
}
private void addItem() {
String item_text = editItem.getText().toString();
if (!item_text.isEmpty()) {
itemlist.add(new ShoppingItem(item_text));
adapter.notifyDataSetChanged();
editItem.setText("");
}
list.smoothScrollToPosition(itemlist.size() - 1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.clear_checked:
clearChecked();
return true;
case R.id.clear_all:
clearAll();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void clearAll() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.confirm);
builder.setMessage(R.string.confirm_clear_all);
builder.setPositiveButton(R.string.clear_all, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
itemlist.clear();
adapter.notifyDataSetChanged();
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.create().show();
}
private void clearChecked() {
int i =0;
while (i < itemlist.size()) {
if (itemlist.get(i).isCheck()) {
itemlist.remove(i);
} else {
i++;
}
}
adapter.notifyDataSetChanged();
}
} | [
"[email protected]"
] | |
c2779e34ff9c2f8e94c4d736f3882d9c9beba413 | 2d8650132bd0a08bb5b8a96d47e5e1c512b5e06a | /Task_6/src/tests/BackpackTest.java | 0de7d73d65a0de4a8f712fe9272814b41d7f0ebe | [] | no_license | OrestTorskyi/TAQC | 0c331d5f6c26881cf1a773337275cf5cd7add8a3 | 6a61a9ecbc308901c9b0ed0af99a4cc665dd3eee | refs/heads/main | 2023-04-01T17:04:35.759878 | 2021-04-08T09:54:47 | 2021-04-08T09:54:47 | 353,450,290 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,253 | java | package tests;
import obj.BackSystem;
import obj.Backpack;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class BackpackTest {
Backpack[] backpacks = new Backpack[6];
List<Integer> objects = new ArrayList<>();
@org.junit.jupiter.api.BeforeEach
void setUp() {
backpacks[0] = new Backpack(BackSystem.NONE);
backpacks[1] = new Backpack(BackSystem.FOAMBACK, "Deuter", 30);
backpacks[2] = new Backpack(BackSystem.NET, "LeadHiking");
backpacks[3] = new Backpack(BackSystem.FOAMBACK, "Deuter", 45);
backpacks[4] = new Backpack(BackSystem.NONE, "The North Face", 55);
backpacks[5] = new Backpack(BackSystem.NET, "Terra Incognita", 30);
objects.add(10);
objects.add(15);
objects.add(25);
}
@org.junit.jupiter.api.AfterEach
void tearDown() {
}
@org.junit.jupiter.api.Test
void fitToBackpack() {
assertEquals(true, backpacks[4].fitToBackpack(objects));
assertEquals(false, backpacks[0].fitToBackpack(objects));
}
@org.junit.jupiter.api.Test
void getBestBackpackFromList() {
assertEquals(backpacks[3], Backpack.getBestBackpackFromList(backpacks));
}
} | [
"[email protected]"
] | |
a21d40c1bf43b8615f047decc8ac644dbcc7e8f8 | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /java/lucene-solr/2018/4/Lucene50PostingsReader.java | 62c7f3f08326f7cd11c7f13801217ac0fcfdf25c | [] | no_license | rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703005 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | null | UTF-8 | Java | false | false | 58,346 | 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.lucene.codecs.lucene50;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
import org.apache.lucene.codecs.BlockTermState;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.codecs.PostingsReaderBase;
import org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.IntBlockTermState;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.ImpactsEnum;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.SlowImpactsEnum;
import org.apache.lucene.search.similarities.Similarity.SimScorer;
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.RamUsageEstimator;
import static org.apache.lucene.codecs.lucene50.ForUtil.MAX_DATA_SIZE;
import static org.apache.lucene.codecs.lucene50.ForUtil.MAX_ENCODED_SIZE;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.BLOCK_SIZE;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.DOC_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.MAX_SKIP_LEVELS;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.PAY_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.POS_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.TERMS_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.VERSION_CURRENT;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.VERSION_START;
/**
* Concrete class that reads docId(maybe frq,pos,offset,payloads) list
* with postings format.
*
* @lucene.experimental
*/
public final class Lucene50PostingsReader extends PostingsReaderBase {
private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(Lucene50PostingsReader.class);
private final IndexInput docIn;
private final IndexInput posIn;
private final IndexInput payIn;
final ForUtil forUtil;
private int version;
/** Sole constructor. */
public Lucene50PostingsReader(SegmentReadState state) throws IOException {
boolean success = false;
IndexInput docIn = null;
IndexInput posIn = null;
IndexInput payIn = null;
// NOTE: these data files are too costly to verify checksum against all the bytes on open,
// but for now we at least verify proper structure of the checksum footer: which looks
// for FOOTER_MAGIC + algorithmID. This is cheap and can detect some forms of corruption
// such as file truncation.
String docName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, Lucene50PostingsFormat.DOC_EXTENSION);
try {
docIn = state.directory.openInput(docName, state.context);
version = CodecUtil.checkIndexHeader(docIn, DOC_CODEC, VERSION_START, VERSION_CURRENT, state.segmentInfo.getId(), state.segmentSuffix);
forUtil = new ForUtil(docIn);
CodecUtil.retrieveChecksum(docIn);
if (state.fieldInfos.hasProx()) {
String proxName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, Lucene50PostingsFormat.POS_EXTENSION);
posIn = state.directory.openInput(proxName, state.context);
CodecUtil.checkIndexHeader(posIn, POS_CODEC, version, version, state.segmentInfo.getId(), state.segmentSuffix);
CodecUtil.retrieveChecksum(posIn);
if (state.fieldInfos.hasPayloads() || state.fieldInfos.hasOffsets()) {
String payName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, Lucene50PostingsFormat.PAY_EXTENSION);
payIn = state.directory.openInput(payName, state.context);
CodecUtil.checkIndexHeader(payIn, PAY_CODEC, version, version, state.segmentInfo.getId(), state.segmentSuffix);
CodecUtil.retrieveChecksum(payIn);
}
}
this.docIn = docIn;
this.posIn = posIn;
this.payIn = payIn;
success = true;
} finally {
if (!success) {
IOUtils.closeWhileHandlingException(docIn, posIn, payIn);
}
}
}
@Override
public void init(IndexInput termsIn, SegmentReadState state) throws IOException {
// Make sure we are talking to the matching postings writer
CodecUtil.checkIndexHeader(termsIn, TERMS_CODEC, VERSION_START, VERSION_CURRENT, state.segmentInfo.getId(), state.segmentSuffix);
final int indexBlockSize = termsIn.readVInt();
if (indexBlockSize != BLOCK_SIZE) {
throw new IllegalStateException("index-time BLOCK_SIZE (" + indexBlockSize + ") != read-time BLOCK_SIZE (" + BLOCK_SIZE + ")");
}
}
/**
* Read values that have been written using variable-length encoding instead of bit-packing.
*/
static void readVIntBlock(IndexInput docIn, int[] docBuffer,
int[] freqBuffer, int num, boolean indexHasFreq) throws IOException {
if (indexHasFreq) {
for(int i=0;i<num;i++) {
final int code = docIn.readVInt();
docBuffer[i] = code >>> 1;
if ((code & 1) != 0) {
freqBuffer[i] = 1;
} else {
freqBuffer[i] = docIn.readVInt();
}
}
} else {
for(int i=0;i<num;i++) {
docBuffer[i] = docIn.readVInt();
}
}
}
@Override
public BlockTermState newTermState() {
return new IntBlockTermState();
}
@Override
public void close() throws IOException {
IOUtils.close(docIn, posIn, payIn);
}
@Override
public void decodeTerm(long[] longs, DataInput in, FieldInfo fieldInfo, BlockTermState _termState, boolean absolute)
throws IOException {
final IntBlockTermState termState = (IntBlockTermState) _termState;
final boolean fieldHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
final boolean fieldHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
final boolean fieldHasPayloads = fieldInfo.hasPayloads();
if (absolute) {
termState.docStartFP = 0;
termState.posStartFP = 0;
termState.payStartFP = 0;
}
termState.docStartFP += longs[0];
if (fieldHasPositions) {
termState.posStartFP += longs[1];
if (fieldHasOffsets || fieldHasPayloads) {
termState.payStartFP += longs[2];
}
}
if (termState.docFreq == 1) {
termState.singletonDocID = in.readVInt();
} else {
termState.singletonDocID = -1;
}
if (fieldHasPositions) {
if (termState.totalTermFreq > BLOCK_SIZE) {
termState.lastPosBlockOffset = in.readVLong();
} else {
termState.lastPosBlockOffset = -1;
}
}
if (termState.docFreq > BLOCK_SIZE) {
termState.skipOffset = in.readVLong();
} else {
termState.skipOffset = -1;
}
}
@Override
public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, PostingsEnum reuse, int flags) throws IOException {
boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
boolean indexHasPayloads = fieldInfo.hasPayloads();
if (indexHasPositions == false || PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) == false) {
BlockDocsEnum docsEnum;
if (reuse instanceof BlockDocsEnum) {
docsEnum = (BlockDocsEnum) reuse;
if (!docsEnum.canReuse(docIn, fieldInfo)) {
docsEnum = new BlockDocsEnum(fieldInfo);
}
} else {
docsEnum = new BlockDocsEnum(fieldInfo);
}
return docsEnum.reset((IntBlockTermState) termState, flags);
} else if ((indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) &&
(indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) {
BlockPostingsEnum docsAndPositionsEnum;
if (reuse instanceof BlockPostingsEnum) {
docsAndPositionsEnum = (BlockPostingsEnum) reuse;
if (!docsAndPositionsEnum.canReuse(docIn, fieldInfo)) {
docsAndPositionsEnum = new BlockPostingsEnum(fieldInfo);
}
} else {
docsAndPositionsEnum = new BlockPostingsEnum(fieldInfo);
}
return docsAndPositionsEnum.reset((IntBlockTermState) termState);
} else {
EverythingEnum everythingEnum;
if (reuse instanceof EverythingEnum) {
everythingEnum = (EverythingEnum) reuse;
if (!everythingEnum.canReuse(docIn, fieldInfo)) {
everythingEnum = new EverythingEnum(fieldInfo);
}
} else {
everythingEnum = new EverythingEnum(fieldInfo);
}
return everythingEnum.reset((IntBlockTermState) termState, flags);
}
}
@Override
public ImpactsEnum impacts(FieldInfo fieldInfo, BlockTermState state, SimScorer scorer, int flags) throws IOException {
Objects.requireNonNull(scorer);
if (state.docFreq <= BLOCK_SIZE || version < Lucene50PostingsFormat.VERSION_IMPACT_SKIP_DATA) {
// no skip data
return new SlowImpactsEnum(postings(fieldInfo, state, null, flags), scorer.score(Float.MAX_VALUE, 1));
}
return new BlockImpactsEverythingEnum(fieldInfo, (IntBlockTermState) state, scorer, flags);
}
final class BlockDocsEnum extends PostingsEnum {
private final byte[] encoded;
private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] freqBuffer = new int[MAX_DATA_SIZE];
private int docBufferUpto;
private Lucene50SkipReader skipper;
private boolean skipped;
final IndexInput startDocIn;
IndexInput docIn;
final boolean indexHasFreq;
final boolean indexHasPos;
final boolean indexHasOffsets;
final boolean indexHasPayloads;
private int docFreq; // number of docs in this posting list
private long totalTermFreq; // sum of freqs in this posting list (or docFreq when omitted)
private int docUpto; // how many docs we've read
private int doc; // doc we last read
private int accum; // accumulator for doc deltas
private int freq; // freq we last read
// Where this term's postings start in the .doc file:
private long docTermStartFP;
// Where this term's skip data starts (after
// docTermStartFP) in the .doc file (or -1 if there is
// no skip data for this term):
private long skipOffset;
// docID for next skip point, we won't use skipper if
// target docID is not larger than this
private int nextSkipDoc;
private boolean needsFreq; // true if the caller actually needs frequencies
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
public BlockDocsEnum(FieldInfo fieldInfo) throws IOException {
this.startDocIn = Lucene50PostingsReader.this.docIn;
this.docIn = null;
indexHasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
indexHasPos = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
indexHasPayloads = fieldInfo.hasPayloads();
encoded = new byte[MAX_ENCODED_SIZE];
}
public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) {
return docIn == startDocIn &&
indexHasFreq == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0) &&
indexHasPos == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) &&
indexHasPayloads == fieldInfo.hasPayloads();
}
public PostingsEnum reset(IntBlockTermState termState, int flags) throws IOException {
docFreq = termState.docFreq;
totalTermFreq = indexHasFreq ? termState.totalTermFreq : docFreq;
docTermStartFP = termState.docStartFP;
skipOffset = termState.skipOffset;
singletonDocID = termState.singletonDocID;
if (docFreq > 1) {
if (docIn == null) {
// lazy init
docIn = startDocIn.clone();
}
docIn.seek(docTermStartFP);
}
doc = -1;
this.needsFreq = PostingsEnum.featureRequested(flags, PostingsEnum.FREQS);
if (indexHasFreq == false || needsFreq == false) {
Arrays.fill(freqBuffer, 1);
}
accum = 0;
docUpto = 0;
nextSkipDoc = BLOCK_SIZE - 1; // we won't skip if target is found in first block
docBufferUpto = BLOCK_SIZE;
skipped = false;
return this;
}
@Override
public int freq() throws IOException {
return freq;
}
@Override
public int nextPosition() throws IOException {
return -1;
}
@Override
public int startOffset() throws IOException {
return -1;
}
@Override
public int endOffset() throws IOException {
return -1;
}
@Override
public BytesRef getPayload() throws IOException {
return null;
}
@Override
public int docID() {
return doc;
}
private void refillDocs() throws IOException {
final int left = docFreq - docUpto;
assert left > 0;
if (left >= BLOCK_SIZE) {
forUtil.readBlock(docIn, encoded, docDeltaBuffer);
if (indexHasFreq) {
if (needsFreq) {
forUtil.readBlock(docIn, encoded, freqBuffer);
} else {
forUtil.skipBlock(docIn); // skip over freqs
}
}
} else if (docFreq == 1) {
docDeltaBuffer[0] = singletonDocID;
freqBuffer[0] = (int) totalTermFreq;
} else {
// Read vInts:
readVIntBlock(docIn, docDeltaBuffer, freqBuffer, left, indexHasFreq);
}
docBufferUpto = 0;
}
@Override
public int nextDoc() throws IOException {
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
accum += docDeltaBuffer[docBufferUpto];
docUpto++;
doc = accum;
freq = freqBuffer[docBufferUpto];
docBufferUpto++;
return doc;
}
@Override
public int advance(int target) throws IOException {
// TODO: make frq block load lazy/skippable
// current skip docID < docIDs generated from current buffer <= next skip docID
// we don't need to skip if target is buffered already
if (docFreq > BLOCK_SIZE && target > nextSkipDoc) {
if (skipper == null) {
// Lazy init: first time this enum has ever been used for skipping
skipper = new Lucene50SkipReader(version,
docIn.clone(),
MAX_SKIP_LEVELS,
indexHasPos,
indexHasOffsets,
indexHasPayloads);
}
if (!skipped) {
assert skipOffset != -1;
// This is the first time this enum has skipped
// since reset() was called; load the skip data:
skipper.init(docTermStartFP+skipOffset, docTermStartFP, 0, 0, docFreq);
skipped = true;
}
// always plus one to fix the result, since skip position in Lucene50SkipReader
// is a little different from MultiLevelSkipListReader
final int newDocUpto = skipper.skipTo(target) + 1;
if (newDocUpto > docUpto) {
// Skipper moved
assert newDocUpto % BLOCK_SIZE == 0 : "got " + newDocUpto;
docUpto = newDocUpto;
// Force to read next block
docBufferUpto = BLOCK_SIZE;
accum = skipper.getDoc(); // actually, this is just lastSkipEntry
docIn.seek(skipper.getDocPointer()); // now point to the block we want to search
}
// next time we call advance, this is used to
// foresee whether skipper is necessary.
nextSkipDoc = skipper.getNextSkipDoc();
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
// Now scan... this is an inlined/pared down version
// of nextDoc():
while (true) {
accum += docDeltaBuffer[docBufferUpto];
docUpto++;
if (accum >= target) {
break;
}
docBufferUpto++;
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
}
freq = freqBuffer[docBufferUpto];
docBufferUpto++;
return doc = accum;
}
@Override
public long cost() {
return docFreq;
}
}
final class BlockPostingsEnum extends PostingsEnum {
private final byte[] encoded;
private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] freqBuffer = new int[MAX_DATA_SIZE];
private final int[] posDeltaBuffer = new int[MAX_DATA_SIZE];
private int docBufferUpto;
private int posBufferUpto;
private Lucene50SkipReader skipper;
private boolean skipped;
final IndexInput startDocIn;
IndexInput docIn;
final IndexInput posIn;
final boolean indexHasOffsets;
final boolean indexHasPayloads;
private int docFreq; // number of docs in this posting list
private long totalTermFreq; // number of positions in this posting list
private int docUpto; // how many docs we've read
private int doc; // doc we last read
private int accum; // accumulator for doc deltas
private int freq; // freq we last read
private int position; // current position
// how many positions "behind" we are; nextPosition must
// skip these to "catch up":
private int posPendingCount;
// Lazy pos seek: if != -1 then we must seek to this FP
// before reading positions:
private long posPendingFP;
// Where this term's postings start in the .doc file:
private long docTermStartFP;
// Where this term's postings start in the .pos file:
private long posTermStartFP;
// Where this term's payloads/offsets start in the .pay
// file:
private long payTermStartFP;
// File pointer where the last (vInt encoded) pos delta
// block is. We need this to know whether to bulk
// decode vs vInt decode the block:
private long lastPosBlockFP;
// Where this term's skip data starts (after
// docTermStartFP) in the .doc file (or -1 if there is
// no skip data for this term):
private long skipOffset;
private int nextSkipDoc;
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
public BlockPostingsEnum(FieldInfo fieldInfo) throws IOException {
this.startDocIn = Lucene50PostingsReader.this.docIn;
this.docIn = null;
this.posIn = Lucene50PostingsReader.this.posIn.clone();
encoded = new byte[MAX_ENCODED_SIZE];
indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
indexHasPayloads = fieldInfo.hasPayloads();
}
public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) {
return docIn == startDocIn &&
indexHasOffsets == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) &&
indexHasPayloads == fieldInfo.hasPayloads();
}
public PostingsEnum reset(IntBlockTermState termState) throws IOException {
docFreq = termState.docFreq;
docTermStartFP = termState.docStartFP;
posTermStartFP = termState.posStartFP;
payTermStartFP = termState.payStartFP;
skipOffset = termState.skipOffset;
totalTermFreq = termState.totalTermFreq;
singletonDocID = termState.singletonDocID;
if (docFreq > 1) {
if (docIn == null) {
// lazy init
docIn = startDocIn.clone();
}
docIn.seek(docTermStartFP);
}
posPendingFP = posTermStartFP;
posPendingCount = 0;
if (termState.totalTermFreq < BLOCK_SIZE) {
lastPosBlockFP = posTermStartFP;
} else if (termState.totalTermFreq == BLOCK_SIZE) {
lastPosBlockFP = -1;
} else {
lastPosBlockFP = posTermStartFP + termState.lastPosBlockOffset;
}
doc = -1;
accum = 0;
docUpto = 0;
if (docFreq > BLOCK_SIZE) {
nextSkipDoc = BLOCK_SIZE - 1; // we won't skip if target is found in first block
} else {
nextSkipDoc = NO_MORE_DOCS; // not enough docs for skipping
}
docBufferUpto = BLOCK_SIZE;
skipped = false;
return this;
}
@Override
public int freq() throws IOException {
return freq;
}
@Override
public int docID() {
return doc;
}
private void refillDocs() throws IOException {
final int left = docFreq - docUpto;
assert left > 0;
if (left >= BLOCK_SIZE) {
forUtil.readBlock(docIn, encoded, docDeltaBuffer);
forUtil.readBlock(docIn, encoded, freqBuffer);
} else if (docFreq == 1) {
docDeltaBuffer[0] = singletonDocID;
freqBuffer[0] = (int) totalTermFreq;
} else {
// Read vInts:
readVIntBlock(docIn, docDeltaBuffer, freqBuffer, left, true);
}
docBufferUpto = 0;
}
private void refillPositions() throws IOException {
if (posIn.getFilePointer() == lastPosBlockFP) {
final int count = (int) (totalTermFreq % BLOCK_SIZE);
int payloadLength = 0;
for(int i=0;i<count;i++) {
int code = posIn.readVInt();
if (indexHasPayloads) {
if ((code & 1) != 0) {
payloadLength = posIn.readVInt();
}
posDeltaBuffer[i] = code >>> 1;
if (payloadLength != 0) {
posIn.seek(posIn.getFilePointer() + payloadLength);
}
} else {
posDeltaBuffer[i] = code;
}
if (indexHasOffsets) {
if ((posIn.readVInt() & 1) != 0) {
// offset length changed
posIn.readVInt();
}
}
}
} else {
forUtil.readBlock(posIn, encoded, posDeltaBuffer);
}
}
@Override
public int nextDoc() throws IOException {
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
doc = accum;
position = 0;
return doc;
}
@Override
public int advance(int target) throws IOException {
// TODO: make frq block load lazy/skippable
if (target > nextSkipDoc) {
if (skipper == null) {
// Lazy init: first time this enum has ever been used for skipping
skipper = new Lucene50SkipReader(version,
docIn.clone(),
MAX_SKIP_LEVELS,
true,
indexHasOffsets,
indexHasPayloads);
}
if (!skipped) {
assert skipOffset != -1;
// This is the first time this enum has skipped
// since reset() was called; load the skip data:
skipper.init(docTermStartFP+skipOffset, docTermStartFP, posTermStartFP, payTermStartFP, docFreq);
skipped = true;
}
final int newDocUpto = skipper.skipTo(target) + 1;
if (newDocUpto > docUpto) {
// Skipper moved
assert newDocUpto % BLOCK_SIZE == 0 : "got " + newDocUpto;
docUpto = newDocUpto;
// Force to read next block
docBufferUpto = BLOCK_SIZE;
accum = skipper.getDoc();
docIn.seek(skipper.getDocPointer());
posPendingFP = skipper.getPosPointer();
posPendingCount = skipper.getPosBufferUpto();
}
nextSkipDoc = skipper.getNextSkipDoc();
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
// Now scan... this is an inlined/pared down version
// of nextDoc():
while (true) {
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
if (accum >= target) {
break;
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
}
position = 0;
return doc = accum;
}
// TODO: in theory we could avoid loading frq block
// when not needed, ie, use skip data to load how far to
// seek the pos pointer ... instead of having to load frq
// blocks only to sum up how many positions to skip
private void skipPositions() throws IOException {
// Skip positions now:
int toSkip = posPendingCount - freq;
final int leftInBlock = BLOCK_SIZE - posBufferUpto;
if (toSkip < leftInBlock) {
posBufferUpto += toSkip;
} else {
toSkip -= leftInBlock;
while(toSkip >= BLOCK_SIZE) {
assert posIn.getFilePointer() != lastPosBlockFP;
forUtil.skipBlock(posIn);
toSkip -= BLOCK_SIZE;
}
refillPositions();
posBufferUpto = toSkip;
}
position = 0;
}
@Override
public int nextPosition() throws IOException {
assert posPendingCount > 0;
if (posPendingFP != -1) {
posIn.seek(posPendingFP);
posPendingFP = -1;
// Force buffer refill:
posBufferUpto = BLOCK_SIZE;
}
if (posPendingCount > freq) {
skipPositions();
posPendingCount = freq;
}
if (posBufferUpto == BLOCK_SIZE) {
refillPositions();
posBufferUpto = 0;
}
position += posDeltaBuffer[posBufferUpto++];
posPendingCount--;
return position;
}
@Override
public int startOffset() {
return -1;
}
@Override
public int endOffset() {
return -1;
}
@Override
public BytesRef getPayload() {
return null;
}
@Override
public long cost() {
return docFreq;
}
}
// Also handles payloads + offsets
final class EverythingEnum extends PostingsEnum {
private final byte[] encoded;
private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] freqBuffer = new int[MAX_DATA_SIZE];
private final int[] posDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] payloadLengthBuffer;
private final int[] offsetStartDeltaBuffer;
private final int[] offsetLengthBuffer;
private byte[] payloadBytes;
private int payloadByteUpto;
private int payloadLength;
private int lastStartOffset;
private int startOffset;
private int endOffset;
private int docBufferUpto;
private int posBufferUpto;
private Lucene50SkipReader skipper;
private boolean skipped;
final IndexInput startDocIn;
IndexInput docIn;
final IndexInput posIn;
final IndexInput payIn;
final BytesRef payload;
final boolean indexHasOffsets;
final boolean indexHasPayloads;
private int docFreq; // number of docs in this posting list
private long totalTermFreq; // number of positions in this posting list
private int docUpto; // how many docs we've read
private int doc; // doc we last read
private int accum; // accumulator for doc deltas
private int freq; // freq we last read
private int position; // current position
// how many positions "behind" we are; nextPosition must
// skip these to "catch up":
private int posPendingCount;
// Lazy pos seek: if != -1 then we must seek to this FP
// before reading positions:
private long posPendingFP;
// Lazy pay seek: if != -1 then we must seek to this FP
// before reading payloads/offsets:
private long payPendingFP;
// Where this term's postings start in the .doc file:
private long docTermStartFP;
// Where this term's postings start in the .pos file:
private long posTermStartFP;
// Where this term's payloads/offsets start in the .pay
// file:
private long payTermStartFP;
// File pointer where the last (vInt encoded) pos delta
// block is. We need this to know whether to bulk
// decode vs vInt decode the block:
private long lastPosBlockFP;
// Where this term's skip data starts (after
// docTermStartFP) in the .doc file (or -1 if there is
// no skip data for this term):
private long skipOffset;
private int nextSkipDoc;
private boolean needsOffsets; // true if we actually need offsets
private boolean needsPayloads; // true if we actually need payloads
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
public EverythingEnum(FieldInfo fieldInfo) throws IOException {
this.startDocIn = Lucene50PostingsReader.this.docIn;
this.docIn = null;
this.posIn = Lucene50PostingsReader.this.posIn.clone();
this.payIn = Lucene50PostingsReader.this.payIn.clone();
encoded = new byte[MAX_ENCODED_SIZE];
indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
if (indexHasOffsets) {
offsetStartDeltaBuffer = new int[MAX_DATA_SIZE];
offsetLengthBuffer = new int[MAX_DATA_SIZE];
} else {
offsetStartDeltaBuffer = null;
offsetLengthBuffer = null;
startOffset = -1;
endOffset = -1;
}
indexHasPayloads = fieldInfo.hasPayloads();
if (indexHasPayloads) {
payloadLengthBuffer = new int[MAX_DATA_SIZE];
payloadBytes = new byte[128];
payload = new BytesRef();
} else {
payloadLengthBuffer = null;
payloadBytes = null;
payload = null;
}
}
public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) {
return docIn == startDocIn &&
indexHasOffsets == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) &&
indexHasPayloads == fieldInfo.hasPayloads();
}
public EverythingEnum reset(IntBlockTermState termState, int flags) throws IOException {
docFreq = termState.docFreq;
docTermStartFP = termState.docStartFP;
posTermStartFP = termState.posStartFP;
payTermStartFP = termState.payStartFP;
skipOffset = termState.skipOffset;
totalTermFreq = termState.totalTermFreq;
singletonDocID = termState.singletonDocID;
if (docFreq > 1) {
if (docIn == null) {
// lazy init
docIn = startDocIn.clone();
}
docIn.seek(docTermStartFP);
}
posPendingFP = posTermStartFP;
payPendingFP = payTermStartFP;
posPendingCount = 0;
if (termState.totalTermFreq < BLOCK_SIZE) {
lastPosBlockFP = posTermStartFP;
} else if (termState.totalTermFreq == BLOCK_SIZE) {
lastPosBlockFP = -1;
} else {
lastPosBlockFP = posTermStartFP + termState.lastPosBlockOffset;
}
this.needsOffsets = PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS);
this.needsPayloads = PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS);
doc = -1;
accum = 0;
docUpto = 0;
if (docFreq > BLOCK_SIZE) {
nextSkipDoc = BLOCK_SIZE - 1; // we won't skip if target is found in first block
} else {
nextSkipDoc = NO_MORE_DOCS; // not enough docs for skipping
}
docBufferUpto = BLOCK_SIZE;
skipped = false;
return this;
}
@Override
public int freq() throws IOException {
return freq;
}
@Override
public int docID() {
return doc;
}
private void refillDocs() throws IOException {
final int left = docFreq - docUpto;
assert left > 0;
if (left >= BLOCK_SIZE) {
forUtil.readBlock(docIn, encoded, docDeltaBuffer);
forUtil.readBlock(docIn, encoded, freqBuffer);
} else if (docFreq == 1) {
docDeltaBuffer[0] = singletonDocID;
freqBuffer[0] = (int) totalTermFreq;
} else {
readVIntBlock(docIn, docDeltaBuffer, freqBuffer, left, true);
}
docBufferUpto = 0;
}
private void refillPositions() throws IOException {
if (posIn.getFilePointer() == lastPosBlockFP) {
final int count = (int) (totalTermFreq % BLOCK_SIZE);
int payloadLength = 0;
int offsetLength = 0;
payloadByteUpto = 0;
for(int i=0;i<count;i++) {
int code = posIn.readVInt();
if (indexHasPayloads) {
if ((code & 1) != 0) {
payloadLength = posIn.readVInt();
}
payloadLengthBuffer[i] = payloadLength;
posDeltaBuffer[i] = code >>> 1;
if (payloadLength != 0) {
if (payloadByteUpto + payloadLength > payloadBytes.length) {
payloadBytes = ArrayUtil.grow(payloadBytes, payloadByteUpto + payloadLength);
}
posIn.readBytes(payloadBytes, payloadByteUpto, payloadLength);
payloadByteUpto += payloadLength;
}
} else {
posDeltaBuffer[i] = code;
}
if (indexHasOffsets) {
int deltaCode = posIn.readVInt();
if ((deltaCode & 1) != 0) {
offsetLength = posIn.readVInt();
}
offsetStartDeltaBuffer[i] = deltaCode >>> 1;
offsetLengthBuffer[i] = offsetLength;
}
}
payloadByteUpto = 0;
} else {
forUtil.readBlock(posIn, encoded, posDeltaBuffer);
if (indexHasPayloads) {
if (needsPayloads) {
forUtil.readBlock(payIn, encoded, payloadLengthBuffer);
int numBytes = payIn.readVInt();
if (numBytes > payloadBytes.length) {
payloadBytes = ArrayUtil.grow(payloadBytes, numBytes);
}
payIn.readBytes(payloadBytes, 0, numBytes);
} else {
// this works, because when writing a vint block we always force the first length to be written
forUtil.skipBlock(payIn); // skip over lengths
int numBytes = payIn.readVInt(); // read length of payloadBytes
payIn.seek(payIn.getFilePointer() + numBytes); // skip over payloadBytes
}
payloadByteUpto = 0;
}
if (indexHasOffsets) {
if (needsOffsets) {
forUtil.readBlock(payIn, encoded, offsetStartDeltaBuffer);
forUtil.readBlock(payIn, encoded, offsetLengthBuffer);
} else {
// this works, because when writing a vint block we always force the first length to be written
forUtil.skipBlock(payIn); // skip over starts
forUtil.skipBlock(payIn); // skip over lengths
}
}
}
}
@Override
public int nextDoc() throws IOException {
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
doc = accum;
position = 0;
lastStartOffset = 0;
return doc;
}
@Override
public int advance(int target) throws IOException {
// TODO: make frq block load lazy/skippable
if (target > nextSkipDoc) {
if (skipper == null) {
// Lazy init: first time this enum has ever been used for skipping
skipper = new Lucene50SkipReader(version,
docIn.clone(),
MAX_SKIP_LEVELS,
true,
indexHasOffsets,
indexHasPayloads);
}
if (!skipped) {
assert skipOffset != -1;
// This is the first time this enum has skipped
// since reset() was called; load the skip data:
skipper.init(docTermStartFP+skipOffset, docTermStartFP, posTermStartFP, payTermStartFP, docFreq);
skipped = true;
}
final int newDocUpto = skipper.skipTo(target) + 1;
if (newDocUpto > docUpto) {
// Skipper moved
assert newDocUpto % BLOCK_SIZE == 0 : "got " + newDocUpto;
docUpto = newDocUpto;
// Force to read next block
docBufferUpto = BLOCK_SIZE;
accum = skipper.getDoc();
docIn.seek(skipper.getDocPointer());
posPendingFP = skipper.getPosPointer();
payPendingFP = skipper.getPayPointer();
posPendingCount = skipper.getPosBufferUpto();
lastStartOffset = 0; // new document
payloadByteUpto = skipper.getPayloadByteUpto();
}
nextSkipDoc = skipper.getNextSkipDoc();
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
// Now scan:
while (true) {
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
if (accum >= target) {
break;
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
}
position = 0;
lastStartOffset = 0;
return doc = accum;
}
// TODO: in theory we could avoid loading frq block
// when not needed, ie, use skip data to load how far to
// seek the pos pointer ... instead of having to load frq
// blocks only to sum up how many positions to skip
private void skipPositions() throws IOException {
// Skip positions now:
int toSkip = posPendingCount - freq;
// if (DEBUG) {
// System.out.println(" FPR.skipPositions: toSkip=" + toSkip);
// }
final int leftInBlock = BLOCK_SIZE - posBufferUpto;
if (toSkip < leftInBlock) {
int end = posBufferUpto + toSkip;
while(posBufferUpto < end) {
if (indexHasPayloads) {
payloadByteUpto += payloadLengthBuffer[posBufferUpto];
}
posBufferUpto++;
}
} else {
toSkip -= leftInBlock;
while(toSkip >= BLOCK_SIZE) {
assert posIn.getFilePointer() != lastPosBlockFP;
forUtil.skipBlock(posIn);
if (indexHasPayloads) {
// Skip payloadLength block:
forUtil.skipBlock(payIn);
// Skip payloadBytes block:
int numBytes = payIn.readVInt();
payIn.seek(payIn.getFilePointer() + numBytes);
}
if (indexHasOffsets) {
forUtil.skipBlock(payIn);
forUtil.skipBlock(payIn);
}
toSkip -= BLOCK_SIZE;
}
refillPositions();
payloadByteUpto = 0;
posBufferUpto = 0;
while(posBufferUpto < toSkip) {
if (indexHasPayloads) {
payloadByteUpto += payloadLengthBuffer[posBufferUpto];
}
posBufferUpto++;
}
}
position = 0;
lastStartOffset = 0;
}
@Override
public int nextPosition() throws IOException {
assert posPendingCount > 0;
if (posPendingFP != -1) {
posIn.seek(posPendingFP);
posPendingFP = -1;
if (payPendingFP != -1) {
payIn.seek(payPendingFP);
payPendingFP = -1;
}
// Force buffer refill:
posBufferUpto = BLOCK_SIZE;
}
if (posPendingCount > freq) {
skipPositions();
posPendingCount = freq;
}
if (posBufferUpto == BLOCK_SIZE) {
refillPositions();
posBufferUpto = 0;
}
position += posDeltaBuffer[posBufferUpto];
if (indexHasPayloads) {
payloadLength = payloadLengthBuffer[posBufferUpto];
payload.bytes = payloadBytes;
payload.offset = payloadByteUpto;
payload.length = payloadLength;
payloadByteUpto += payloadLength;
}
if (indexHasOffsets) {
startOffset = lastStartOffset + offsetStartDeltaBuffer[posBufferUpto];
endOffset = startOffset + offsetLengthBuffer[posBufferUpto];
lastStartOffset = startOffset;
}
posBufferUpto++;
posPendingCount--;
return position;
}
@Override
public int startOffset() {
return startOffset;
}
@Override
public int endOffset() {
return endOffset;
}
@Override
public BytesRef getPayload() {
if (payloadLength == 0) {
return null;
} else {
return payload;
}
}
@Override
public long cost() {
return docFreq;
}
}
final class BlockImpactsEverythingEnum extends ImpactsEnum {
private final byte[] encoded;
private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] freqBuffer = new int[MAX_DATA_SIZE];
private final int[] posDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] payloadLengthBuffer;
private final int[] offsetStartDeltaBuffer;
private final int[] offsetLengthBuffer;
private byte[] payloadBytes;
private int payloadByteUpto;
private int payloadLength;
private int lastStartOffset;
private int startOffset = -1;
private int endOffset = -1;
private int docBufferUpto;
private int posBufferUpto;
private final Lucene50ScoreSkipReader skipper;
final IndexInput docIn;
final IndexInput posIn;
final IndexInput payIn;
final BytesRef payload;
final boolean indexHasFreq;
final boolean indexHasPos;
final boolean indexHasOffsets;
final boolean indexHasPayloads;
private int docFreq; // number of docs in this posting list
private long totalTermFreq; // number of positions in this posting list
private int docUpto; // how many docs we've read
private int doc; // doc we last read
private int accum; // accumulator for doc deltas
private int freq; // freq we last read
private int position; // current position
// how many positions "behind" we are; nextPosition must
// skip these to "catch up":
private int posPendingCount;
// Lazy pos seek: if != -1 then we must seek to this FP
// before reading positions:
private long posPendingFP;
// Lazy pay seek: if != -1 then we must seek to this FP
// before reading payloads/offsets:
private long payPendingFP;
// Where this term's postings start in the .doc file:
private long docTermStartFP;
// Where this term's postings start in the .pos file:
private long posTermStartFP;
// Where this term's payloads/offsets start in the .pay
// file:
private long payTermStartFP;
// File pointer where the last (vInt encoded) pos delta
// block is. We need this to know whether to bulk
// decode vs vInt decode the block:
private long lastPosBlockFP;
private int nextSkipDoc = -1;
private final boolean needsPositions;
private final boolean needsOffsets; // true if we actually need offsets
private final boolean needsPayloads; // true if we actually need payloads
private long seekTo = -1;
public BlockImpactsEverythingEnum(FieldInfo fieldInfo, IntBlockTermState termState, SimScorer scorer, int flags) throws IOException {
indexHasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
indexHasPos = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
indexHasPayloads = fieldInfo.hasPayloads();
needsPositions = PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS);
needsOffsets = PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS);
needsPayloads = PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS);
this.docIn = Lucene50PostingsReader.this.docIn.clone();
encoded = new byte[MAX_ENCODED_SIZE];
if (indexHasPos && needsPositions) {
this.posIn = Lucene50PostingsReader.this.posIn.clone();
} else {
this.posIn = null;
}
if ((indexHasOffsets && needsOffsets) || (indexHasPayloads && needsPayloads)) {
this.payIn = Lucene50PostingsReader.this.payIn.clone();
} else {
this.payIn = null;
}
if (indexHasOffsets) {
offsetStartDeltaBuffer = new int[MAX_DATA_SIZE];
offsetLengthBuffer = new int[MAX_DATA_SIZE];
} else {
offsetStartDeltaBuffer = null;
offsetLengthBuffer = null;
startOffset = -1;
endOffset = -1;
}
if (indexHasPayloads) {
payloadLengthBuffer = new int[MAX_DATA_SIZE];
payloadBytes = new byte[128];
payload = new BytesRef();
} else {
payloadLengthBuffer = null;
payloadBytes = null;
payload = null;
}
docFreq = termState.docFreq;
docTermStartFP = termState.docStartFP;
posTermStartFP = termState.posStartFP;
payTermStartFP = termState.payStartFP;
totalTermFreq = termState.totalTermFreq;
docIn.seek(docTermStartFP);
posPendingFP = posTermStartFP;
payPendingFP = payTermStartFP;
posPendingCount = 0;
if (termState.totalTermFreq < BLOCK_SIZE) {
lastPosBlockFP = posTermStartFP;
} else if (termState.totalTermFreq == BLOCK_SIZE) {
lastPosBlockFP = -1;
} else {
lastPosBlockFP = posTermStartFP + termState.lastPosBlockOffset;
}
doc = -1;
accum = 0;
docUpto = 0;
docBufferUpto = BLOCK_SIZE;
skipper = new Lucene50ScoreSkipReader(version,
docIn.clone(),
MAX_SKIP_LEVELS,
indexHasPos,
indexHasOffsets,
indexHasPayloads,
scorer);
skipper.init(docTermStartFP+termState.skipOffset, docTermStartFP, posTermStartFP, payTermStartFP, docFreq);
if (indexHasFreq == false) {
Arrays.fill(freqBuffer, 1);
}
}
@Override
public int freq() throws IOException {
return freq;
}
@Override
public int docID() {
return doc;
}
private void refillDocs() throws IOException {
final int left = docFreq - docUpto;
assert left > 0;
if (left >= BLOCK_SIZE) {
forUtil.readBlock(docIn, encoded, docDeltaBuffer);
if (indexHasFreq) {
forUtil.readBlock(docIn, encoded, freqBuffer);
}
} else {
readVIntBlock(docIn, docDeltaBuffer, freqBuffer, left, indexHasFreq);
}
docBufferUpto = 0;
}
private void refillPositions() throws IOException {
if (posIn.getFilePointer() == lastPosBlockFP) {
final int count = (int) (totalTermFreq % BLOCK_SIZE);
int payloadLength = 0;
int offsetLength = 0;
payloadByteUpto = 0;
for(int i=0;i<count;i++) {
int code = posIn.readVInt();
if (indexHasPayloads) {
if ((code & 1) != 0) {
payloadLength = posIn.readVInt();
}
payloadLengthBuffer[i] = payloadLength;
posDeltaBuffer[i] = code >>> 1;
if (payloadLength != 0) {
if (payloadByteUpto + payloadLength > payloadBytes.length) {
payloadBytes = ArrayUtil.grow(payloadBytes, payloadByteUpto + payloadLength);
}
posIn.readBytes(payloadBytes, payloadByteUpto, payloadLength);
payloadByteUpto += payloadLength;
}
} else {
posDeltaBuffer[i] = code;
}
if (indexHasOffsets) {
int deltaCode = posIn.readVInt();
if ((deltaCode & 1) != 0) {
offsetLength = posIn.readVInt();
}
offsetStartDeltaBuffer[i] = deltaCode >>> 1;
offsetLengthBuffer[i] = offsetLength;
}
}
payloadByteUpto = 0;
} else {
forUtil.readBlock(posIn, encoded, posDeltaBuffer);
if (indexHasPayloads && payIn != null) {
if (needsPayloads) {
forUtil.readBlock(payIn, encoded, payloadLengthBuffer);
int numBytes = payIn.readVInt();
if (numBytes > payloadBytes.length) {
payloadBytes = ArrayUtil.grow(payloadBytes, numBytes);
}
payIn.readBytes(payloadBytes, 0, numBytes);
} else {
// this works, because when writing a vint block we always force the first length to be written
forUtil.skipBlock(payIn); // skip over lengths
int numBytes = payIn.readVInt(); // read length of payloadBytes
payIn.seek(payIn.getFilePointer() + numBytes); // skip over payloadBytes
}
payloadByteUpto = 0;
}
if (indexHasOffsets && payIn != null) {
if (needsOffsets) {
forUtil.readBlock(payIn, encoded, offsetStartDeltaBuffer);
forUtil.readBlock(payIn, encoded, offsetLengthBuffer);
} else {
// this works, because when writing a vint block we always force the first length to be written
forUtil.skipBlock(payIn); // skip over starts
forUtil.skipBlock(payIn); // skip over lengths
}
}
}
}
@Override
public int nextDoc() throws IOException {
return advance(doc + 1);
}
@Override
public float getMaxScore(int upTo) throws IOException {
return skipper.getMaxScore(upTo);
}
@Override
public int advanceShallow(int target) throws IOException {
if (target > nextSkipDoc) {
// always plus one to fix the result, since skip position in Lucene50SkipReader
// is a little different from MultiLevelSkipListReader
final int newDocUpto = skipper.skipTo(target) + 1;
if (newDocUpto > docUpto) {
// Skipper moved
assert newDocUpto % BLOCK_SIZE == 0 : "got " + newDocUpto;
docUpto = newDocUpto;
// Force to read next block
docBufferUpto = BLOCK_SIZE;
accum = skipper.getDoc();
posPendingFP = skipper.getPosPointer();
payPendingFP = skipper.getPayPointer();
posPendingCount = skipper.getPosBufferUpto();
lastStartOffset = 0; // new document
payloadByteUpto = skipper.getPayloadByteUpto(); // actually, this is just lastSkipEntry
seekTo = skipper.getDocPointer(); // delay the seek
}
// next time we call advance, this is used to
// foresee whether skipper is necessary.
nextSkipDoc = skipper.getNextSkipDoc();
}
assert nextSkipDoc >= target;
return nextSkipDoc;
}
@Override
public int advance(int target) throws IOException {
if (target > nextSkipDoc) {
advanceShallow(target);
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
if (seekTo >= 0) {
docIn.seek(seekTo);
seekTo = -1;
}
refillDocs();
}
// Now scan:
while (true) {
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
if (accum >= target) {
break;
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
}
position = 0;
lastStartOffset = 0;
return doc = accum;
}
// TODO: in theory we could avoid loading frq block
// when not needed, ie, use skip data to load how far to
// seek the pos pointer ... instead of having to load frq
// blocks only to sum up how many positions to skip
private void skipPositions() throws IOException {
// Skip positions now:
int toSkip = posPendingCount - freq;
// if (DEBUG) {
// System.out.println(" FPR.skipPositions: toSkip=" + toSkip);
// }
final int leftInBlock = BLOCK_SIZE - posBufferUpto;
if (toSkip < leftInBlock) {
int end = posBufferUpto + toSkip;
while(posBufferUpto < end) {
if (indexHasPayloads) {
payloadByteUpto += payloadLengthBuffer[posBufferUpto];
}
posBufferUpto++;
}
} else {
toSkip -= leftInBlock;
while(toSkip >= BLOCK_SIZE) {
assert posIn.getFilePointer() != lastPosBlockFP;
forUtil.skipBlock(posIn);
if (indexHasPayloads && payIn != null) {
// Skip payloadLength block:
forUtil.skipBlock(payIn);
// Skip payloadBytes block:
int numBytes = payIn.readVInt();
payIn.seek(payIn.getFilePointer() + numBytes);
}
if (indexHasOffsets && payIn != null) {
forUtil.skipBlock(payIn);
forUtil.skipBlock(payIn);
}
toSkip -= BLOCK_SIZE;
}
refillPositions();
payloadByteUpto = 0;
posBufferUpto = 0;
while(posBufferUpto < toSkip) {
if (indexHasPayloads) {
payloadByteUpto += payloadLengthBuffer[posBufferUpto];
}
posBufferUpto++;
}
}
position = 0;
lastStartOffset = 0;
}
@Override
public int nextPosition() throws IOException {
if (indexHasPos == false || needsPositions == false) {
return -1;
}
assert posPendingCount > 0;
if (posPendingFP != -1) {
posIn.seek(posPendingFP);
posPendingFP = -1;
if (payPendingFP != -1 && payIn != null) {
payIn.seek(payPendingFP);
payPendingFP = -1;
}
// Force buffer refill:
posBufferUpto = BLOCK_SIZE;
}
if (posPendingCount > freq) {
skipPositions();
posPendingCount = freq;
}
if (posBufferUpto == BLOCK_SIZE) {
refillPositions();
posBufferUpto = 0;
}
position += posDeltaBuffer[posBufferUpto];
if (indexHasPayloads) {
payloadLength = payloadLengthBuffer[posBufferUpto];
payload.bytes = payloadBytes;
payload.offset = payloadByteUpto;
payload.length = payloadLength;
payloadByteUpto += payloadLength;
}
if (indexHasOffsets && needsOffsets) {
startOffset = lastStartOffset + offsetStartDeltaBuffer[posBufferUpto];
endOffset = startOffset + offsetLengthBuffer[posBufferUpto];
lastStartOffset = startOffset;
}
posBufferUpto++;
posPendingCount--;
return position;
}
@Override
public int startOffset() {
return startOffset;
}
@Override
public int endOffset() {
return endOffset;
}
@Override
public BytesRef getPayload() {
if (payloadLength == 0) {
return null;
} else {
return payload;
}
}
@Override
public long cost() {
return docFreq;
}
}
@Override
public long ramBytesUsed() {
return BASE_RAM_BYTES_USED;
}
@Override
public void checkIntegrity() throws IOException {
if (docIn != null) {
CodecUtil.checksumEntireFile(docIn);
}
if (posIn != null) {
CodecUtil.checksumEntireFile(posIn);
}
if (payIn != null) {
CodecUtil.checksumEntireFile(payIn);
}
}
@Override
public String toString() {
return getClass().getSimpleName() + "(positions=" + (posIn != null) + ",payloads=" + (payIn != null) +")";
}
}
| [
"[email protected]"
] | |
e2ad0e20bd8464b258a773c898654f3ca1c84906 | 13550e8fbae589af18a0af93962c10b27ac50ff6 | /src/programmersLevel1/S01_Kakao.java | e4fe941ad88cd09e95e58c300ae6036ba7ccc1da | [] | no_license | SungWoo824/JavaAlgorithm | 824fff65bee375694cbf3272789c113661d9bee2 | 66e7a4893abace8ffa85f7ef1d2a26b28caa51f3 | refs/heads/master | 2023-08-17T07:12:17.690567 | 2023-08-08T14:09:32 | 2023-08-08T14:09:32 | 214,786,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,343 | java | package programmersLevel1;
import java.util.HashMap;
import java.util.Map;
public class S01_Kakao {
public int[] solution(String[] id_list, String[] report, int k) {
int[] answer = {};
int[] checkArr = new int[id_list.length];
Map<String, Integer> checkMap = new HashMap<>();
Map<String, Integer> userMap = new HashMap<>();
for (int i = 0 ; i < report.length ; i++) {
String[] tempArr = report[i].split(" ");
if (checkMap.containsKey(tempArr[1])) {
checkMap.put(tempArr[1],checkMap.get(tempArr[1])+1);
} else {
checkMap.put(tempArr[1],1);
}
if (userMap.containsKey(tempArr[0])) {
checkMap.put(tempArr[0],checkMap.get(tempArr[0])+1);
} else {
checkMap.put(tempArr[0],1);
}
}
return answer;
}
public static void main(String[] args) {
Map<String, Integer> test = new HashMap<>();
String testString = "test";
test.put("test",1);
System.out.println(test.get("test"));
}
}
/*
id_list report k result
["muzi", "frodo", "apeach", "neo"] ["muzi frodo","apeach frodo","frodo neo","muzi neo","apeach muzi"] 2 [2,1,1,0]
["con", "ryan"] ["ryan con", "ryan con", "ryan con", "ryan con"] 3 [0,0]
*/
| [
"[email protected]"
] | |
a9a2cd078a7a339d0cd270fcb8b6d53664d9b8ff | b16fca18a2eca70bee8cb9c40b1ee5c22e8798ec | /src/main/java/com/casesoft/common/util/Message.java | 337d1ee92e50e219db68610a0428c691afb2dfae | [] | no_license | liutianci1201/casesoft-common | fc8b4fe9430606def0341a8bfa8d9aa6af7e9883 | fb53ebb3134ba3f25481ff82298b1eda80c5442e | refs/heads/master | 2020-03-30T00:20:14.162133 | 2018-09-27T02:31:26 | 2018-09-27T02:31:26 | 150,517,451 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,073 | java | package com.casesoft.common.util;
import java.io.Serializable;
import com.alibaba.fastjson.JSONObject;
public class Message implements Serializable {
private static final long serialVersionUID = -4303499387889592642L;
private String code;
private String message;
private JSONObject info;
public Message() {
}
public Message(String code) {
super();
this.code = code;
}
public Message(String code, String message) {
super();
this.code = code;
this.message = message;
}
public Message(String code, JSONObject info) {
super();
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public JSONObject getInfo() {
return info;
}
public void setInfo(JSONObject info) {
this.info = info;
}
@Override
public String toString() {
return "Message [code=" + code + ", message=" + message + ", info=" + info + "]";
}
}
| [
"[email protected]"
] | |
3a6ef1220bd618cd7d52ea511d41da24d6f00241 | 4d6f0e9c036218d5829b6ac2d054248056e13038 | /myPackage/transectionManagement/AccountTransactions.java | 7df18855b645c555181f2352230a9b153f3af20c | [
"Apache-2.0"
] | permissive | Saidul-M-Khan/Bank-Management-System | 8ff9f234b9648f14b54c320a962ba5041192ad16 | 8f5dfee7b78c393128eda727731a549aa70fe6cb | refs/heads/master | 2022-12-31T23:35:34.758296 | 2020-10-18T20:53:24 | 2020-10-18T20:53:24 | 297,986,240 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | package myPackage.transectionManagement;
interface AccountTransactions
{
void deposit(double amount_of_money);
void withdraw(double amount_of_money);
void transfer(Account account, double amount_of_money);
} | [
"[email protected]"
] | |
2547b9d70b319712c9753b4a2866328ee4c4a71a | fe06f97c2cf33a8b4acb7cb324b79a6cb6bb9dac | /java/po/impl/FTZC_AP/PreIndtlPo.java | f3355cabb5d3b80499545bd4342409cba50d57ee | [] | 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,918 | java | package com.doc.common.po.impl;
public class PreIndtlPo implements IPreIndtlPo {
public enum COLUMNS {
BF_NO("null"), //
GOODS_CODE("null"), //
COMMODITY_NO("null"), //
GOODS_UNIT("null"), //
IN_STORAGE_AREA("null"), //
GOODS_QTY("null"), //
GOODS_DESC("null"), //
DECL_NO("null"), //
GUID("null"), //
DECL_TYPE("null"), //
IN_DATE("null"), //
ITEM_NO("null"), //
DUTY_TYPE("null"), //
STAT_MODE("null"), //
BOM_NO("null"), //
BOM_VER("null"), //
PRDT_MARK("null") //
;
private final String comment;
private COLUMNS(final String comment) {
this.comment = comment;
}
public String getComment() {
return this.comment;
}
}
private String bfNo;
private String goodsCode;
private String commodityNo;
private String goodsUnit;
private String inStorageArea;
private BigDecimal goodsQty;
private String goodsDesc;
private String declNo;
private String guid;
private String declType;
private String inDate;
private BigDecimal itemNo;
private String dutyType;
private String statMode;
private String bomNo;
private String bomVer;
private String prdtMark;
@Override
public String getBfNo() {
return this.bfNo;
}
@Override
public void setBfNo(final String bfNo) {
this.bfNo = bfNo;
}
@Override
public String getGoodsCode() {
return this.goodsCode;
}
@Override
public void setGoodsCode(final String goodsCode) {
this.goodsCode = goodsCode;
}
@Override
public String getCommodityNo() {
return this.commodityNo;
}
@Override
public void setCommodityNo(final String commodityNo) {
this.commodityNo = commodityNo;
}
@Override
public String getGoodsUnit() {
return this.goodsUnit;
}
@Override
public void setGoodsUnit(final String goodsUnit) {
this.goodsUnit = goodsUnit;
}
@Override
public String getInStorageArea() {
return this.inStorageArea;
}
@Override
public void setInStorageArea(final String inStorageArea) {
this.inStorageArea = inStorageArea;
}
@Override
public BigDecimal getGoodsQty() {
return this.goodsQty;
}
@Override
public void setGoodsQty(final BigDecimal goodsQty) {
this.goodsQty = goodsQty;
}
@Override
public String getGoodsDesc() {
return this.goodsDesc;
}
@Override
public void setGoodsDesc(final String goodsDesc) {
this.goodsDesc = goodsDesc;
}
@Override
public String getDeclNo() {
return this.declNo;
}
@Override
public void setDeclNo(final String declNo) {
this.declNo = declNo;
}
@Override
public String getGuid() {
return this.guid;
}
@Override
public void setGuid(final String guid) {
this.guid = guid;
}
@Override
public String getDeclType() {
return this.declType;
}
@Override
public void setDeclType(final String declType) {
this.declType = declType;
}
@Override
public String getInDate() {
return this.inDate;
}
@Override
public void setInDate(final String inDate) {
this.inDate = inDate;
}
@Override
public BigDecimal getItemNo() {
return this.itemNo;
}
@Override
public void setItemNo(final BigDecimal itemNo) {
this.itemNo = itemNo;
}
@Override
public String getDutyType() {
return this.dutyType;
}
@Override
public void setDutyType(final String dutyType) {
this.dutyType = dutyType;
}
@Override
public String getStatMode() {
return this.statMode;
}
@Override
public void setStatMode(final String statMode) {
this.statMode = statMode;
}
@Override
public String getBomNo() {
return this.bomNo;
}
@Override
public void setBomNo(final String bomNo) {
this.bomNo = bomNo;
}
@Override
public String getBomVer() {
return this.bomVer;
}
@Override
public void setBomVer(final String bomVer) {
this.bomVer = bomVer;
}
@Override
public String getPrdtMark() {
return this.prdtMark;
}
@Override
public void setPrdtMark(final String prdtMark) {
this.prdtMark = prdtMark;
}
}
| [
"[email protected]"
] | |
0e6c2a1b5341b6c3f0ac3e954bf9a58903e3158e | c422df5be5b4dfcefafda3b2f53b8b60e57ede19 | /LinkedList_Driver.java | fb64a238931e21ecf91c300ee4be9db85925530c | [] | no_license | revachauhan/workspace | 32f927d8f1f8aeade879eb3bbb7bfe313d14b53e | 8f26f5f3919df15abcf5bea90fe1d1eea1788275 | refs/heads/master | 2021-05-28T08:46:30.174846 | 2014-03-04T04:25:37 | 2014-03-04T04:25:37 | 13,977,460 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 359 | java | package reva.java.practice;
public class LinkedList_Driver {
public static void main(String[] args) {
LinkedList list = new LinkedList();
int i =1;
while(i <5)
{
list.insert(i);
i++;
}
list.print(list);
list.delete(2);
list.print(list);
list.insert_in_front(12);
list.print(list);
System.out.println(list.find(4));
}
}
| [
"[email protected]"
] | |
64a4af93224dc1df0b969df1c589d1b4e5cf26de | 66c86bc3cc1089aee81bc39416f891feb4989aeb | /src/test/java/com/ceitechs/pro/domain/service/service/AttachmentServiceTest.java | 0c09dfa7a12a5aca662e6a311a5112e4ddc3d3c6 | [] | no_license | CEITECHS/pro-domain-service | efd908dfbf5b7b4f25cc3998e7a29c9cbad53bb1 | 30d8767f297c2e28760f0484b05156e144ca628c | refs/heads/master | 2021-01-01T06:52:04.299893 | 2017-09-21T23:09:09 | 2017-09-21T23:09:09 | 97,533,876 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,137 | java | /**
*
*/
package com.ceitechs.pro.domain.service.service;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Optional;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import com.ceitechs.pro.domain.service.AbstractProDomainServiceIntegrationTest;
import com.ceitechs.pro.domain.service.domain.Attachment;
import com.ceitechs.pro.domain.service.domain.Pro;
import com.ceitechs.pro.domain.service.repositories.AttachmentRepository;
import com.ceitechs.pro.domain.service.repositories.AttachmentRepositoryTest;
import com.ceitechs.pro.domain.service.util.ProUtility;
/**
* @author vctrowino
*
*/
public class AttachmentServiceTest extends AbstractProDomainServiceIntegrationTest{
@Autowired
private AttachmentService attachmentService;
@Autowired
private AttachmentRepository attachmentRepository;
@Test(expected = RuntimeException.class)
public void storeAttachmentWithoutActualAttachmentTest() {
Attachment attachment = AttachmentRepositoryTest.createAttachment();
attachment.setAttachment(null);
Pro pro = new Pro();
pro.setProReferenceId(ProUtility.generateIdAsString());
attachmentService.storeAttachment(pro, attachment);
}
@Test
public void storeAttachmentWithActualAttachmentTest() throws IOException {
attachmentRepository.deleteAll();
Attachment attachment = AttachmentRepositoryTest.createAttachment();
Pro pro = new Pro();
pro.setProReferenceId(ProUtility.generateIdAsString());
attachment.setAttachment(new MockMultipartFile(resource.getFilename(), resource.getInputStream()));
Optional<Attachment> attachmentOptional = attachmentService.storeAttachment(pro, attachment);
assertTrue(attachmentOptional.isPresent());
assertNotNull(attachmentOptional.get().getUrl());
System.out.println(attachmentOptional.get().getUrl());
}
}
| [
"[email protected]"
] | |
0d9f060bfcef219926e50473d68fabf734a0b10b | 602dbfdc2a22f1764e76611a39b8b7cfba611239 | /src/demos/nehe/lesson42/Lesson42.java | f1387c8a3190986841739d3f3c3e7fc0e14139b3 | [] | no_license | linghushaoxia/nehe-swt | a69bc49e76546f5b12e38238b27025569b086690 | 33cf299667abdae306557fbed43b42434b36cc0b | refs/heads/master | 2021-01-20T22:02:44.652758 | 2015-10-02T10:09:17 | 2015-10-02T10:09:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 489 | java | package demos.nehe.lesson42;
import demos.common.GLDisplay;
/**
* @author Pepijn Van Eeckhoudt
*/
public class Lesson42 {
public static void main(String[] args) {
GLDisplay neheGLDisplay = GLDisplay.createGLDisplay("Lesson 42: Multiple viewports");
Renderer renderer = new Renderer();
InputHandler inputHandler = new InputHandler(renderer, neheGLDisplay);
neheGLDisplay.addGLEventListener(renderer);
neheGLDisplay.addKeyListener(inputHandler);
neheGLDisplay.start();
}
}
| [
"[email protected]"
] | |
ce7b4c0d5c118b4985aa12b78fcdc4dfa27772e4 | 26f921c58071e02b999ff6b5628fec5e915d7b81 | /src/pattern/bridge/RandomCountDisplay.java | 88dcb02136724df699af90d1e2b315d3e47a1610 | [] | no_license | lispe/DesignPattern | 313dd47e3cd6bf5956e4a8852d6926f3d240e1ed | 37faa120922200115991a126e22fa70cad30f98b | refs/heads/master | 2021-08-27T21:28:02.296960 | 2017-12-10T11:43:01 | 2017-12-10T11:43:01 | 113,745,062 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 422 | java | package pattern.bridge;
import java.util.Random;
public class RandomCountDisplay extends CountDisplay {
Random random = new Random();
public RandomCountDisplay(DisplayImpl impl) {
super(impl);
}
/**
* 0以上、指定回数未満だけランダムに表示する。
* @param times 指定回数
*/
public void randomDisplay(int times) {
multiDisplay(random.nextInt(times));
}
}
| [
"[email protected]"
] | |
164dc17f7d7d263c0ff3c8fd40cbe99131d0848e | 7e0a42622c381947bdb1a7e95e919edd391d171c | /gulimall-ware/src/main/java/com/atguigu/gulimall/ware/dao/PurchaseDetailDao.java | 2a47b4925449a8cc7ed7b4ab663cf4f546c98369 | [] | no_license | qi17/guli | 17533a2acadb2abd0ece03f88ea6061155ff4b1a | 3d364c8f9a5c0f7b6b392a32f69e58f52644e8ac | refs/heads/master | 2023-04-26T05:15:55.253271 | 2021-05-30T03:09:37 | 2021-05-30T03:09:37 | 372,111,938 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 391 | java | package com.atguigu.gulimall.ware.dao;
import com.atguigu.gulimall.ware.entity.PurchaseDetailEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author qichunhui
* @email [email protected]
* @date 2021-04-04 17:01:18
*/
@Mapper
public interface PurchaseDetailDao extends BaseMapper<PurchaseDetailEntity> {
}
| [
"[email protected]"
] | |
5c4f7240d87996b860a67d0393943c6f6f4a367f | babcc5556adfebefa1f8ae2dbf0b756ed48ba08c | /src/test/java/learn/field_agent/data/SecurityClearanceJdbcTemplateRepositoryTest.java | 91dc1b3809ceb375e4ad5ec5932b732c6477a3e4 | [] | no_license | ElderBass/Field_Agent_Dev10 | 6053235372a0a1aea1275d8697ad57765f9047df | 2789972a8ed1688bd83781ee6f9c25ce4ad1f459 | refs/heads/master | 2023-06-22T05:28:39.779235 | 2021-07-13T19:41:36 | 2021-07-13T19:41:36 | 381,460,005 | 0 | 0 | null | 2021-07-14T03:49:47 | 2021-06-29T18:23:52 | Java | UTF-8 | Java | false | false | 3,220 | java | package learn.field_agent.data;
import learn.field_agent.models.SecurityClearance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
class SecurityClearanceJdbcTemplateRepositoryTest {
@Autowired
SecurityClearanceJdbcTemplateRepository repository;
@Autowired
KnownGoodState knownGoodState;
@BeforeEach
void setup() {
knownGoodState.set();
}
@Test
void shouldFindById() {
SecurityClearance secret = new SecurityClearance(1, "Secret");
SecurityClearance topSecret = new SecurityClearance(2, "Top Secret");
SecurityClearance actual = repository.findById(1);
assertEquals(secret, actual);
actual = repository.findById(2);
assertEquals(topSecret, actual);
actual = repository.findById(80);
assertEquals(null, actual);
}
@Test
void shouldFindAll() {
List<SecurityClearance> all = repository.findAll();
assertNotNull(all);
assertTrue(all.size() >= 2);
SecurityClearance expected = new SecurityClearance();
expected.setSecurityClearanceId(1);
expected.setName("Secret");
assertTrue(all.contains(expected)
&& all.stream().anyMatch(i -> i.getSecurityClearanceId() == 2));
}
@Test
void shouldAdd() {
SecurityClearance sc = new SecurityClearance(3, "Sort of Secret");
SecurityClearance added = repository.add(sc);
assertEquals(3, repository.findAll().size());
assertEquals("Sort of Secret", repository.findById(3).getName());
}
@Test
void shouldUpdateExisting() {
SecurityClearance sc = new SecurityClearance();
sc.setSecurityClearanceId(2);
sc.setName("Semi-Secret");
assertTrue(repository.update(sc));
assertEquals(sc, repository.findById(2));
}
@Test
void shouldNotUpdateMissing() {
SecurityClearance sc = new SecurityClearance();
sc.setSecurityClearanceId(20000);
sc.setName("Super Secret");
assertFalse(repository.update(sc));
}
@Test
void shouldDelete() {
SecurityClearance sc = new SecurityClearance(0, "Sort of Secret");
SecurityClearance added = repository.add(sc);
assertEquals(4, repository.findAll().size());
String isDeleted = repository.deleteById(4);
assertEquals("Deleted Successfully.", isDeleted);
}
@Test
void shouldNotDeleteMissing() {
String result = repository.deleteById(2000);
assertEquals("Could not find Security Clearance with ID 2000", result);
}
@Test
void shouldNotDeleteClearanceInUse() {
String result = repository.deleteById(1);
assertEquals("Security Clearance 1 in active use - cannot delete at this time.", result);
}
} | [
"[email protected]"
] | |
02e5edd2eaac4a5591c13593767e6d1dfe2aec07 | 7bea7fb60b5f60f89f546a12b43ca239e39255b5 | /src/java/util/Stack.java | f8248f4cc1957300bca0bfa0e46a9ade84aa9d94 | [] | no_license | sorakeet/fitcorejdk | 67623ab26f1defb072ab473f195795262a8ddcdd | f946930a826ddcd688b2ddbb5bc907d2fc4174c3 | refs/heads/master | 2021-01-01T05:52:19.696053 | 2017-07-15T01:33:41 | 2017-07-15T01:33:41 | 97,292,673 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 930 | java | /**
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package java.util;
public class Stack<E> extends Vector<E>{
private static final long serialVersionUID=1224463164541339165L;
public Stack(){
}
public E push(E item){
addElement(item);
return item;
}
public synchronized E pop(){
E obj;
int len=size();
obj=peek();
removeElementAt(len-1);
return obj;
}
public synchronized E peek(){
int len=size();
if(len==0)
throw new EmptyStackException();
return elementAt(len-1);
}
public boolean empty(){
return size()==0;
}
public synchronized int search(Object o){
int i=lastIndexOf(o);
if(i>=0){
return size()-i;
}
return -1;
}
}
| [
"panxiaoping@9af151c5-2e68-9a40-a710-8967c58c11f7"
] | panxiaoping@9af151c5-2e68-9a40-a710-8967c58c11f7 |
3b06a37a5f02379537a8ac256604c1721d5c28e1 | d8ad34475c721d8a3a87590fe43664982d8055b7 | /sources/JavaSE/src/StringDemo.java | 8b7c463bd56268fd66a62cc84b1aebeb10f56838 | [] | no_license | coding-technology/JavaCore | 64090ad4a9f19cd67be90a7714aaf7241972c34a | 7d0bff6f2dc03af1bf819a4c0378dae3ae5fc236 | refs/heads/master | 2022-11-23T20:13:51.551061 | 2020-09-20T08:56:11 | 2020-09-20T08:56:11 | 200,790,681 | 26 | 19 | null | 2022-11-16T10:59:02 | 2019-08-06T06:32:37 | Java | UTF-8 | Java | false | false | 5,345 | java | public class StringDemo {
static String s3;//有默认值 null
//字符串基本操作
public static void test1() {
//定义字符串方式一:
String s = "abcd";
System.out.println(s);
//基本类型 int num = 10 ;
//对象类型: Person per = new Person();
//定义字符串方式二:
String s1 = "helloworld";
System.out.println(s1);
//方式三
String s2 = ""; //方式三 默认生成的s2是 ""
System.out.println(s2.equals(""));//“”
System.out.println(s2 == null);//null
System.out.println("s3" + s3);
//常见的String方法
String str = " hello world ";
boolean flag = str.equals("helloWorlD");
//忽略大小写 比较
boolean flag2 = str.equalsIgnoreCase("helloWorlD");
System.out.println(flag);
System.out.println(flag2);
int len = str.length();//字符串长度
System.out.println(len);
//转为大写
str = str.toUpperCase();
System.out.println(str);
//转为小写
str = str.toLowerCase();
System.out.println(str);
//helloworld
//判断 字符串A 是否存在于 另一个字符串B中,如果存在 ,则返回位置;如果不存在,返回-1
//int position = str.indexOf('o') ; //char ->int
int position = str.lastIndexOf('o');
System.out.println(position);
//str
System.out.println(str);
System.out.println("实际长度" + str.length());
str = str.trim();//去掉首尾空格,不会去掉中间的
System.out.println("去掉首尾空格之后的 长度" + str.length());
}
//验证 邮箱是否 合法 [email protected] 15768995.com
public static boolean isValidateEmail(String email) {
//合法情况
return email.indexOf("@") != -1 && email.indexOf(".") != -1 &&
email.indexOf("@") < email.indexOf(".");
}
//校验 电话是否合法
public static void testSubstring() {
//029-88888888
// String phone = "18055555555" ;
//座机要求: 区号是 3或4位 ,右侧 8位
String phone = "029-123456789";
if (phone.indexOf("-") != -1) {
System.out.println("座机号码");
//phone.substring(start,end) : [start,end)
//phone.substring(start) : 从start到最后
// phone = phone.substring(2,6); //>=2 <6
// System.out.println(phone);
// 区号是 3或4位 ,右侧 8位
// 截取区号
int start = 0;
int end = phone.indexOf("-");
// "029" "0931"
String zone = phone.substring(start, end);
if (zone.length() == 3 || zone.length() == 4) {
System.out.println("区号正确");
} else {
System.out.println("区号有误!");
}
//座机的右侧:"029-12345678" ;
int startRight = end + 1;
String numberStr = phone.substring(startRight);
if (numberStr.length() == 8) {
System.out.println("号码正确");
} else {
System.out.println("号码有误!");
}
} else {
System.out.println("手机号码");
}
}
public static void testSubstring2(String phone) {
//029-88888888
// String phone = "18055555555" ;
//座机要求: 区号是 3或4位 ,右侧 8位
// String phone = "029-12345678" ;
if (phone.indexOf("-") != -1) {
System.out.println("座机号码");
int start = 0;
int end = phone.indexOf("-");
// "029" "0931"
String zone = phone.substring(start, end);
//座机的右侧:"029-12345678" ;
int startRight = end + 1;
String numberStr = phone.substring(startRight);
//正确: 区号正确 且 号码正确
if ((zone.length() == 3 || zone.length() == 4) && (numberStr.length() == 8)) {
System.out.println("座机正确");
} else {
System.out.println("座机有误!");
}
} else {
//18888888888
System.out.println("手机号码");
String first = phone.substring(0, 1);
if (first.equals("1") && phone.length() == 11) {
System.out.println("正确的手机号");
} else {
System.out.println("错误的手机号");
}
}
}
public static void testSplit() {
String phone = "029-12345-678";
String[] ps = phone.split("-");
for (String p : ps) {
System.out.println(p);
}
// System.out.println(ps[0]);
// System.out.println(ps[1]);
// System.out.println(ps[2]);
}
//staitc->static
public static void main(String[] args) {
// boolean result = isValidateEmail("[email protected]");
// System.out.println(result==true ? "合法":"不合法" );
// testSubstring();
// testSubstring2("029-54548787");
testSplit();
}
}
| [
"[email protected]"
] | |
7efcdf688a1b3c1bf65d9d9706f15a231d1cb998 | 48c61bdd1cb92138dca1dbfcd4531d3a1d81472a | /_02_Tools_Basic/_28_Spinner/_07_Editable_Spinner/MyConverter.java | 91551f0b3a2a7a82244b53a0c54ab2b4ff5cb06e | [] | no_license | Majd-Talji/JavaFX | b907c85bd9061aef35bb29de68cf907430ca0b47 | d2f29d15dcb1ed3d1b24b3393eb73ac942b47cac | refs/heads/master | 2022-05-31T22:35:22.990795 | 2020-05-03T16:25:16 | 2020-05-03T16:25:16 | 260,971,476 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 425 | java | package _02_Tools_Basic._28_Spinner._07_Editable_Spinner;
import javafx.util.StringConverter;
/**
*
* @author Majd Talji <[email protected]>
*/
public class MyConverter extends StringConverter<Integer> {
@Override
public String toString(Integer object) {
return object + "";
}
@Override
public Integer fromString(String string) {
return Integer.parseInt(string);
}
}
| [
"[email protected]"
] | |
9bae7a8a0aff020fe2747f146089f39779b94d17 | 77d47629438fcfd20d7d7878ea0582969d0f8c22 | /Assignment1/Beg_Java_14/Beg_Java_14/Solutions to Exercises/Ch07/sol2/ClassifyIndexException.java | 8407e27a97e91bef29d1e7d4d70bf98b176efcf4 | [] | no_license | kirouchenaradjou/WebTools | 3fba43a0123a3ff57ba714fa9d18b057e545bcb1 | 3d9dfdc71cd7f7f53462b61dde9a629d8dba7e7d | refs/heads/master | 2021-04-27T19:52:30.954375 | 2019-02-03T01:07:45 | 2019-02-03T01:07:45 | 122,365,594 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,365 | java | // Chapter 7 Exercise 2
// ClassifyIndexException class
public class ClassifyIndexException extends Throwable {
private int index = -1; // Index of array element causing error.
private String exception; // String identifying exception.
// Default Constructor:
public ClassifyIndexException() {
exception = "Index value is not known."; // Set defaults for exception string.
}
// Standard constructor:
public ClassifyIndexException(String s) {
super(s); // Call the base constructor.
exception = "Index value is not known."; // Set defaults for exception string.
}
public ClassifyIndexException(int index) {
super("Index is not within scope of array.\n"); // Call the base constructor.
this.index = index; // Set the index value.
if(index < 0) { // Check for negative index.
exception = "Index to array is negative. Index = " + index;
}
else { // Index value must be too high:
exception = "Index to array is beyond last array element. Index = "+index;
}
}
// Get the array index value for the error:
public int getIndex() {
return index; // Return the index value.
}
// Override inherited method for a more informative message string:
public String toString() {
return getMessage() + exception;
}
}
| [
"[email protected]"
] | |
a5f85dc91178171bf5f6d47d6d27916fc2ac46cf | 32f38cd53372ba374c6dab6cc27af78f0a1b0190 | /app/src/main/java/com/autonavi/jni/ae/pos/LocDRPos.java | 5e714c977a517290c13658159b4ef6542c6a8bee | [] | no_license | shuixi2013/AmapCode | 9ea7aefb42e0413f348f238f0721c93245f4eac6 | 1a3a8d4dddfcc5439df8df570000cca12b15186a | refs/heads/master | 2023-06-06T23:08:57.391040 | 2019-08-29T04:36:02 | 2019-08-29T04:36:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 970 | java | package com.autonavi.jni.ae.pos;
public class LocDRPos {
public int DRStatus;
public float alt;
public float altAcc;
public float course;
public float courseAcc;
public int day;
public float deltaAlt;
public float deltaAltAcc;
public char ew;
public int gpsStatus;
public float hdop;
public int hour;
public boolean isDeltaAltAccValid;
public boolean isDeltaAltValid;
public boolean isMoveDistValid;
public boolean isSlopeAccValid;
public boolean isSlopeValueValid;
public int lat;
public int lon;
public int minute;
public int month;
public double moveDist;
public int moveStatus;
public char ns;
public float pdop;
public float posAcc;
public int satnum;
public int second;
public float slopeAcc;
public float slopeValue;
public float speed;
public float speedAcc;
public long ticktime64;
public float vdop;
public int year;
}
| [
"[email protected]"
] | |
302ceda79f6ed505f569b7d74afaa3eac3506b90 | 8a4fe4d680269376a57bf1a7de610992972fa867 | /app/src/main/java/com/vr_mu/vrmu/gson/BannerGson.java | aebcf29bd0a8c2ab2cf43a8cd959d3287c3ba033 | [
"Apache-2.0"
] | permissive | qiezi0301/VRMU | cb8118c7486be57647c8297ad2c3925846b7b60c | 72225050f377508eb92ea2b8d9104361b5c9173a | refs/heads/master | 2021-01-22T21:41:11.005331 | 2017-04-14T10:17:56 | 2017-04-14T10:17:56 | 85,462,354 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 953 | java | package com.vr_mu.vrmu.gson;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by zjl on 17/4/12.
*/
public class BannerGson {
/**
* code : 0
* msg : success
* data : [{"id":1,"img":"http://api.vr-mu.com/Uploads/banner/img/banner1.jpg"},{"id":2,"img":"http://api.vr-mu.com/Uploads/banner/img/banner2.jpg"},{"id":3,"img":"http://api.vr-mu.com/Uploads/banner/img/banner3.jpg"}]
* location :
*/
@SerializedName("code")
public int code;
@SerializedName("msg")
public String msg;
@SerializedName("location")
public String location;
@SerializedName("data")
public List<DataBean> data;
public static class DataBean {
/**
* id : 1
* img : http://api.vr-mu.com/Uploads/banner/img/banner1.jpg
*/
@SerializedName("id")
public int id;
@SerializedName("img")
public String img;
}
}
| [
"[email protected]"
] | |
d67a2bd642a8a585a007dda4824a7af0d2fbcb16 | a69111fa92dfae7daefdb1bb0790889ed2fab960 | /app/src/test/java/com/example/sajkaan/stormy/ExampleUnitTest.java | 176c041a479569c94a21fe8cf1a520f19b34b63c | [] | no_license | Sajkaan/Stormy | d9afdccbd7c0ef2a6252e5ba324b787c5856d228 | f3a382d1e9b7a21c178adf30162e9372349efd11 | refs/heads/master | 2021-01-17T15:51:40.743581 | 2016-09-25T17:00:14 | 2016-09-25T17:00:14 | 69,068,479 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 404 | java | package com.example.sajkaan.stormy;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
98af3e3ba208880ea7318c759606edfd5ebb071d | e8d587ee5c601ed9b4ce228c202bf7db278a9d82 | /ProjectPasswordStrengthMeter/app/src/main/java/com/example/johan/projectpasswordstrengthmeter/PasswordRequirements.java | a408d35bb3419d8004a0a91a683426a9534b6661 | [] | no_license | Syllvan/Interaction-programming | 2edeb387adbe3c00379ebd6d6e38bb44eb4fec2c | 7bfc32c8dd937db30a11ad874a1126b67c73482b | refs/heads/master | 2021-01-10T15:10:00.679268 | 2016-01-13T10:01:02 | 2016-01-13T10:01:02 | 49,324,708 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,912 | java | package com.example.johan.projectpasswordstrengthmeter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by johan on 2016-01-05.
*/
public class PasswordRequirements {
private int minCharacters;
public PasswordRequirements(){
minCharacters = 5;
}
public boolean containsMinimum(String s){
if ( s.length()>= minCharacters){
return true;
}
else {
return false;
}
}
public boolean containsUpper(String s){
for(int i=0; i < s.length(); i++){
if(Character.isUpperCase(s.charAt(i))){
return true;
}
}
return false;
}
public boolean containsLower(String s){
for(int i=0; i < s.length(); i++){
if(Character.isLowerCase(s.charAt(i))){
return true;
}
}
return false;
}
public boolean containsNumber(String s){
for(int i=0; i < s.length(); i++){
if(Character.isDigit(s.charAt(i))){
return true;
}
}
return false;
}
public boolean containsSpecial(String s){
Pattern p = Pattern.compile("[^a-z0-9 ]", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(s);
boolean b = m.find();
if (b){
return true;
}
else {
return false;
}
}
public int passwordStrengthLevel(String s){
int strengthLevel = 0;
if(containsMinimum(s)){
strengthLevel++;
}
if(containsUpper(s)){
strengthLevel++;
}
if(containsLower(s)){
strengthLevel++;
}
if(containsNumber(s)){
strengthLevel++;
}
if(containsSpecial(s)){
strengthLevel++;
}
return strengthLevel;
}
}
| [
"[email protected]"
] | |
f32f98c76ed10aa8faa95670012c646ed9769c36 | 47225f6683b9ce1408aa95fb1ec36d953485b53a | /rover.service/src/main/java/rover/tasks/CollectTask.java | 1cce452c2e5b019ae7f640104f599d1976c9162c | [] | no_license | AKAfreaky/IntelligentAgentsRover | e6fc332134d4590ca6d38b1edefb0cfe9c1e2f12 | 8019468a86d7de358d0c6899da80cb928fe790a6 | refs/heads/master | 2021-01-20T22:28:54.983079 | 2014-01-05T23:52:14 | 2014-01-05T23:52:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,282 | java | package rover.tasks;
import rover.PollResult;
import rover.ResourceInfo;
import rover.RoverInfo;
import rover.RoverServiceImpl;
public class CollectTask extends Task {
private ResourceInfo ri;
public CollectTask(RoverInfo rover, RoverServiceImpl impl, ResourceInfo ri) {
super(rover, impl, 5000);
this.ri = ri;
setEnergyPerSecond(1);
//adjust count down
ri.setCount(ri.getCount()- 1);
}
@Override
public void Cancel() {
// reduce rover power and add resource
// back to world
ri.setCount(ri.getCount()+ 1);
adjustEnergy();
}
@Override
public void Complete() {
// add resource to rover and reduce power
adjustEnergy();
getRover().setPollResult(new PollResult(PollResult.COLLECT, PollResult.COMPLETE));
getRover().setCurrentLoad(getRover().getCurrentLoad() + 1);
}
@Override
public void Update() {
// don't need to do anything
adjustEnergy();
if(getRover().getEnergy() < 0) {
PollResult pr = new PollResult(PollResult.COLLECT, PollResult.FAILED);
pr.setPercentComplete(percentComplete());
getRover().setPollResult(pr);
//add resource back
ri.setCount(ri.getCount()+ 1);
getRover().setTask(null);
}
}
@Override
public int taskNum() {
return PollResult.COLLECT;
}
}
| [
"[email protected]"
] | |
bdc93667a3bdfb22529fdd9837898fad7a26b294 | ba835146483ae9df12b126b3133110e9030b73ec | /structure/src/MyStackAndQueue/MyQueue2.java | 3447852400182cd1f92df2c43126e768813186c4 | [] | no_license | 2170987947/dataStructure | 69aa5920d01177e470f0367d7c678629ff82c120 | c1fada6f7e0170403cb3f38c8c2a0dae78024a41 | refs/heads/master | 2023-04-28T13:52:00.739161 | 2021-05-15T07:57:18 | 2021-05-15T07:57:18 | 329,228,497 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 982 | java | package MyStackAndQueue;
/**
* @author FMM
* @version 7.0
* @date 2021/3/9 14:15
*/
public class MyQueue2 {
private int[] queue = new int[10];
private int head = 0;
private int tail = 0;
private int size;
public boolean offer(int e) {
if (this.size >= queue.length) {
return false;
}
if (this.tail + 1 == this.queue.length) {
this.tail = 0;
} else {
this.queue[tail++] = e;
}
this.size++;
return true;
}
public Integer peek() {
if (this.size <= 0) {
return null;
}
return this.queue[this.head];
}
public Integer poll() {
if (this.size <= 0) {
return null;
}
int result = this.queue[this.head];
if (this.head + 1 == this.queue.length) {
this.head = 0;
} else {
this.head++;
}
this.size--;
return result;
}
}
| [
"[email protected]"
] | |
84d179614a3653982d48fb815de27bdc0d960306 | dc5a822f13e6d4cd1b5cf7615c410647224a5054 | /algorithm0721/src/palindrome/main.java | 1d81912e3792458c9ca2097998afb36d7fb72378 | [] | no_license | jibminJung/algorithm-test | 7ce0eec839775650789cd13f8af85a13089d72cb | 4a57a0c3358979d1ea4c2eb6379c4ee9408bdbd0 | refs/heads/master | 2023-07-18T12:44:54.948232 | 2021-08-28T07:29:31 | 2021-08-28T07:29:31 | 400,174,773 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,049 | java | package palindrome;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
while (n-- > 0) {
String target = br.readLine();
int left = 0;
int right = target.length() - 1;
int type = 0;
while (left <= right) {
if (target.charAt(left) == target.charAt(right)) {
left++;
right--;
} else {
int l = left;
int r = right;
l++;
while (l <= r) {
if (target.charAt(l) == target.charAt(r)) {
l++;
r--;
} else {
type++;
break;
}
}
l = left;
r = right;
r--;
while (l <= r) {
if (target.charAt(l) == target.charAt(r)) {
l++;
r--;
} else {
type++;
break;
}
}
}
if (type > 0)
break;
}
System.out.println(type);
}
}
}
| [
"tunej@DESKTOP-NB2UBHG"
] | tunej@DESKTOP-NB2UBHG |
d6631b27a92069259755d2d6ced059302eb9373a | 83d1876a13882b00175c36474391631c5fa0ea9d | /src/main/java/com/sinjinsong/leetcode/hard/LeetCode128.java | 81d106ac2827b70cda19067a8a7c71cb5db8f81b | [] | no_license | songxinjianqwe/DataStructures | acc9c103666526bb14ef6cf35396c9321d0b5a9b | 53fe5e9ac1605990e3a20bfd4b5c003e9ed60010 | refs/heads/master | 2021-07-01T19:31:32.594899 | 2021-02-01T16:17:58 | 2021-02-01T16:17:58 | 74,250,991 | 5 | 1 | null | null | null | null | UTF-8 | Java | false | false | 770 | java | package com.sinjinsong.leetcode.hard;
import java.util.HashSet;
import java.util.Set;
public class LeetCode128 {
public int longestConsecutive(int[] nums) {
if(nums.length <= 1) {
return nums.length;
}
Set<Integer> set = new HashSet<>();
for (int num : nums) {
set.add(num);
}
int ans = 1;
for (int num : nums) {
if(set.contains(num - 1)) {
continue;
}
if(set.contains(num + 1)) {
int dist = 1;
int val = num + 1;
while(set.contains(val++)) {
dist++;
}
ans = Math.max(ans, dist);
}
}
return ans;
}
}
| [
"[email protected]"
] | |
fba2362913efee4687d66bbc7c38cbfae7aff25b | 7112ce5c2a3f9ab9f36c7c8cf94c2ef627ac7813 | /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AmpSensorTest.java | 575780977ac7f913044d5a18af9855ba8fcdb8d2 | [] | no_license | Aedificatores8581/relic-recovery | be2fab873bdfef808926a173a87430defa72c426 | 5d6bfca50a29df86849ee31b251ae1d437119baf | refs/heads/master | 2022-01-16T13:29:18.573003 | 2019-07-24T15:31:46 | 2019-07-24T15:31:46 | 95,800,731 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,665 | java | package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.AnalogInput;
import com.qualcomm.robotcore.hardware.AnalogOutput;
import com.qualcomm.robotcore.hardware.Gamepad;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.DigitalChannel;
/**
* Created by Hunter Seachrist on 2/9/2018.
*/
@Disabled
@TeleOp(name = "SensorBot: Amp Sensor", group = "Sensor Test")
public class AmpSensorTest extends OpMode {
AnalogInput ampSensor;
Servo testServo;
double servoPosition;
protected DigitalChannel magFront, magBack;
public void init(){
ampSensor = hardwareMap.get(AnalogInput.class, "amp");
testServo = hardwareMap.servo.get("servo");
magFront = hardwareMap.digitalChannel.get("mf");
magBack = hardwareMap.digitalChannel.get("mb");
magFront.setMode(DigitalChannel.Mode.INPUT);
magBack.setMode(DigitalChannel.Mode.INPUT);
}
public void loop(){
testServo.setPosition(servoPosition);
telemetry.addData("Amp Sensor Voltage: " , ampSensor.getVoltage());
telemetry.addData("Amp Sensor max Voltage: " , ampSensor.getMaxVoltage());
if (gamepad1.left_bumper) {
servoPosition += 0.02;
}
else if (gamepad1.right_bumper) {
servoPosition -= 0.02;
}
telemetry.addData("back.getState: ", magBack.getState());
telemetry.addData("front.getState: ", magFront.getState());
}
}
| [
"[email protected]"
] | |
4fce5bb97bc1d1be66b3f7003d8218ca55db0ab3 | 072216667ef59e11cf4994220ea1594538db10a0 | /xiaomi/yellowpages/android/support/a/a/h.java | 594e61d8a4e579142625a76f1f1ebb7491a3d9d6 | [] | no_license | jackTang11/REMIUI | 896037b74e90f64e6f7d8ddfda6f3731a8db6a74 | 48d65600a1b04931a510e1f036e58356af1531c0 | refs/heads/master | 2021-01-18T05:43:37.754113 | 2015-07-03T04:01:06 | 2015-07-03T04:01:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,047 | java | package android.support.a.a;
import android.app.Fragment;
import android.app.Fragment.SavedState;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.D;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
/* compiled from: FragmentStatePagerAdapter */
public abstract class h extends D {
private FragmentTransaction Mf;
private ArrayList Mg;
private ArrayList Mh;
private Fragment Mi;
private final FragmentManager mFragmentManager;
public abstract Fragment r(int i);
public h(FragmentManager fragmentManager) {
this.Mf = null;
this.Mg = new ArrayList();
this.Mh = new ArrayList();
this.Mi = null;
this.mFragmentManager = fragmentManager;
}
public void startUpdate(ViewGroup viewGroup) {
}
public Object instantiateItem(ViewGroup viewGroup, int i) {
if (this.Mh.size() > i) {
Fragment fragment = (Fragment) this.Mh.get(i);
if (fragment != null) {
return fragment;
}
}
if (this.Mf == null) {
this.Mf = this.mFragmentManager.beginTransaction();
}
Fragment r = r(i);
if (this.Mg.size() > i) {
SavedState savedState = (SavedState) this.Mg.get(i);
if (savedState != null) {
r.setInitialSavedState(savedState);
}
}
while (this.Mh.size() <= i) {
this.Mh.add(null);
}
d.b(r, false);
d.a(r, false);
this.Mh.set(i, r);
this.Mf.add(viewGroup.getId(), r);
return r;
}
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
Fragment fragment = (Fragment) obj;
if (this.Mf == null) {
this.Mf = this.mFragmentManager.beginTransaction();
}
while (this.Mg.size() <= i) {
this.Mg.add(null);
}
this.Mg.set(i, this.mFragmentManager.saveFragmentInstanceState(fragment));
this.Mh.set(i, null);
this.Mf.remove(fragment);
}
public void setPrimaryItem(ViewGroup viewGroup, int i, Object obj) {
Fragment fragment = (Fragment) obj;
if (fragment != this.Mi) {
if (this.Mi != null) {
d.b(this.Mi, false);
d.a(this.Mi, false);
}
if (fragment != null) {
d.b(fragment, true);
d.a(fragment, true);
}
this.Mi = fragment;
}
}
public void finishUpdate(ViewGroup viewGroup) {
if (this.Mf != null) {
this.Mf.commitAllowingStateLoss();
this.Mf = null;
this.mFragmentManager.executePendingTransactions();
}
}
public boolean isViewFromObject(View view, Object obj) {
return ((Fragment) obj).getView() == view;
}
public Parcelable saveState() {
Bundle bundle = null;
if (this.Mg.size() > 0) {
bundle = new Bundle();
Parcelable[] parcelableArr = new SavedState[this.Mg.size()];
this.Mg.toArray(parcelableArr);
bundle.putParcelableArray("states", parcelableArr);
}
Parcelable parcelable = bundle;
for (int i = 0; i < this.Mh.size(); i++) {
Fragment fragment = (Fragment) this.Mh.get(i);
if (fragment != null) {
if (parcelable == null) {
parcelable = new Bundle();
}
this.mFragmentManager.putFragment(parcelable, "f" + i, fragment);
}
}
return parcelable;
}
public void restoreState(Parcelable parcelable, ClassLoader classLoader) {
if (parcelable != null) {
Bundle bundle = (Bundle) parcelable;
bundle.setClassLoader(classLoader);
Parcelable[] parcelableArray = bundle.getParcelableArray("states");
this.Mg.clear();
this.Mh.clear();
if (parcelableArray != null) {
for (Parcelable parcelable2 : parcelableArray) {
this.Mg.add((SavedState) parcelable2);
}
}
for (String str : bundle.keySet()) {
if (str.startsWith("f")) {
int parseInt = Integer.parseInt(str.substring(1));
Fragment fragment = this.mFragmentManager.getFragment(bundle, str);
if (fragment != null) {
while (this.Mh.size() <= parseInt) {
this.Mh.add(null);
}
d.b(fragment, false);
this.Mh.set(parseInt, fragment);
} else {
Log.w("FragmentStatePagerAdapter", "Bad fragment at key " + str);
}
}
}
}
}
}
| [
"[email protected]"
] | |
20970c86379b5d8244c424d9bd2727c633abb218 | 32b72e1dc8b6ee1be2e80bb70a03a021c83db550 | /ast_results/fmetzger_android-sensorium/Sensorium/src/org/xmlrpc/android/IXMLRPCSerializer.java | 5de6da09dcd29a176fe5e5ed878340db9bb964f8 | [] | no_license | cmFodWx5YWRhdjEyMTA5/smell-and-machine-learning | d90c41a17e88fcd99d543124eeb6e93f9133cb4a | 0564143d92f8024ff5fa6b659c2baebf827582b1 | refs/heads/master | 2020-07-13T13:53:40.297493 | 2019-01-11T11:51:18 | 2019-01-11T11:51:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,148 | java | // isComment
package org.xmlrpc.android;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
public interface isClassOrIsInterface {
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
// isComment
String isVariable = "isStringConstant";
String isVariable = "isStringConstant";
void isMethod(XmlSerializer isParameter, Object isParameter) throws IOException;
Object isMethod(XmlPullParser isParameter) throws XmlPullParserException, IOException;
}
| [
"[email protected]"
] | |
2221b9cbd7d68d9953275afd9d727e9670d0f5c1 | 1d749a8646a6ca9dc12962e3816c178150517215 | /app/src/main/java/com/example/rated/Adapters/PostDetailAdapter.java | d24bb73c45525210f29874476dc239131ddc3832 | [] | no_license | amirulhakim47/RatedApp | 16bf730ec4c98859420fa3692e80b1ae99258ba8 | f663cf1245b0ef4a94af2378ecf541b2be39eacf | refs/heads/master | 2020-05-03T10:46:53.174859 | 2019-06-18T05:48:33 | 2019-06-18T05:48:33 | 178,587,286 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,126 | java | package com.example.rated.Adapters;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.example.rated.Activities.PostDetailActivity;
import com.example.rated.Models.Comment;
import com.example.rated.R;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import de.hdodenhof.circleimageview.CircleImageView;
public class PostDetailAdapter extends RecyclerView.Adapter<PostDetailAdapter.MyViewHolder> {
private Context mContext;
private List<Comment> mData ;
public PostDetailAdapter(Context mContext, List<Comment> mData) {
this.mContext = mContext;
this.mData = mData;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
View row2 = LayoutInflater.from(mContext).inflate(R.layout.row_comment_item,viewGroup,false);
return new MyViewHolder(row2);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int position) {
Glide.with(mContext).load(mData.get(position).getUimg()).into(myViewHolder.uimg);
myViewHolder.content.setText(mData.get(position).getContent());
myViewHolder.uname.setText(mData.get(position).getUname());
myViewHolder.usrTimeStamp.setText(mData.get(position).getDate());
// Glide.with(mContext).load(mData.get(position).getTimestamp()).into(myViewHolder.usrTimeStamp);
//animation
myViewHolder.uimg.setAnimation(AnimationUtils.loadAnimation(mContext,R.anim.fade_transition_animation));
myViewHolder.container.setAnimation(AnimationUtils.loadAnimation(mContext,R.anim.fade_scale_animation));
}
@Override
public int getItemCount() {
return mData.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder{
TextView content,uname;
TextView usrTimeStamp;
CircleImageView uimg;
LinearLayout container;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
content = (TextView) itemView.findViewById(R.id.comment_content);
uname = (TextView) itemView.findViewById(R.id.comment_uname);
usrTimeStamp = (TextView) itemView.findViewById(R.id.comment_time);
uimg = (CircleImageView) itemView.findViewById(R.id.comment_img);
container = (LinearLayout) itemView.findViewById(R.id.comment_container);
}
}
private String timestampToString(long time) {
Calendar calendar = Calendar.getInstance(Locale.ENGLISH);
calendar.setTimeInMillis(time);
String date = DateFormat.format("dd-MM-yyyy", calendar).toString();
return date;
}
}
| [
"[email protected]"
] | |
ecd16b5bf67503849aeeca12321001c9083ce447 | ebe7183eabbc25fe5e977b4c7e5041c2da32f264 | /src/netgest/bo/xwc/framework/annotations/XUIWebDefaultCommand.java | a30b3184443efc5ef448fa56e605579e7d589d8d | [] | no_license | ITDS-PT/xwc | d3aabba541ef35b043cab04134970f7646596df2 | 62348d12b49b0ae706c7f1b74713a8a8f7334b85 | refs/heads/master | 2021-01-17T07:43:34.254476 | 2017-08-24T02:47:49 | 2017-08-24T02:47:49 | 27,862,552 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | package netgest.bo.xwc.framework.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface XUIWebDefaultCommand {
}
| [
"[email protected]"
] | |
118241cedf5a9d74424b16c706e51ed55a86b33e | 8f44851f6201796c1d5f724d4e3e427d43a83b6e | /wan/src/com/bg/wan/MainActivity.java | a501653d4dbe21196fc86be4e5addf02f4de0f58 | [] | no_license | awtsst/HiGradation | 051fc12274f824823dbbd01d7d097efcced655c4 | e34eb0e4c71749f2f2d00220d450e6342870bc9b | refs/heads/master | 2016-08-12T02:30:57.363154 | 2016-04-01T02:59:51 | 2016-04-01T02:59:51 | 55,197,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 917 | java | package com.bg.wan;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
] | |
ccac7523566a243fb2a0123b4c1e2f0bcacff00f | 606ba140b738deac354d33120f818435cd33c1b3 | /app/src/main/java/cdfproject/com/github/CDFandroidUI/view/phoneBookSuite/PhoneBookAdapter.java | 8151e35debbee3bfa0f4ce631f5b9f0d49233b3a | [] | no_license | cdfproject/CDFandroidUI | 0d7f659c740ead2faa16c994990577d40a7ffd65 | 2849fb29a333daa57489e0398d4cb7b6d3707c56 | refs/heads/master | 2016-09-13T12:39:37.941846 | 2016-04-25T05:53:40 | 2016-04-25T05:53:40 | 57,004,032 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,797 | java | package cdfproject.com.github.CDFandroidUI.view.phoneBookSuite;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import cdfproject.com.github.CDFandroidUI.R;
/**
* 电话本列表适配器
* @author LiuJ
* 电话本列表套件之一
*/
public class PhoneBookAdapter extends Adapter<ViewHolder>{
private static final int OnItemChecked = 200;
private static final int ItemViewType_Division = 233;
private static final int ItemViewType_Contact = 666;
private List<ContactBean> beans;
private Context context;
private OnCheckedPhoneListener checkedPhoneListener;
private int maxCheckSize = 10;
// private HashMap<String, Boolean> checked;//储存已经选择过的项
public PhoneBookAdapter(Context context,List<ContactBean> beans) {
super();
this.beans = beans;
this.context = context;
//根据说明,本行代码会辅助数据显示,防止反复刷新,但是加上之后出现数据重复问题,暂时不纠结
// setHasStableIds(true);
}
@Override
public long getItemId(int position) {
return beans.get(position).getContactId();
}
@Override
public int getItemCount() {
return beans.size();
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
switch (getItemViewType(position)) {
case ItemViewType_Contact:
((ContactHolder)holder).setBeans(beans.get(position),position );
break;
case ItemViewType_Division:
((DivisionHolder)holder).setBeans(beans.get(position));
break;
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case ItemViewType_Contact:
ContactHolder contactHolder = new ContactHolder(
LayoutInflater.from(context).inflate(R.layout.item_contact, parent, false));
return contactHolder;
case ItemViewType_Division:
DivisionHolder divisionHolder = new DivisionHolder(
LayoutInflater.from(context).inflate(R.layout.item_first_letter, parent, false));
return divisionHolder;
}
return null;
}
@Override
public int getItemViewType(int position) {
if(beans.get(position).isPhone()){
return ItemViewType_Contact;
}else{
return ItemViewType_Division;
}
}
private class ContactHolder extends ViewHolder{
public TextView phone;
public TextView name;
private CheckBox checkBox;
private OnItemChecked checked;
private View itemView;
public ContactHolder(View itemView) {
super(itemView);
this.itemView = itemView;
phone = (TextView) itemView.findViewById(R.id.item_contact_tel);
name = (TextView) itemView.findViewById(R.id.item_contact_name);
checkBox = (CheckBox) itemView.findViewById(R.id.item_contact_check);
}
public void setBeans(ContactBean b,int position){
phone.setText(b.getPhoneNum());
name.setText(b.getDesplayName());
checkBox.setChecked(b.isChecked());
checked = new OnItemChecked(position);
itemView.setOnClickListener(checked);
// phone.setOnClickListener(checked);
// checkBox.setOnCheckedChangeListener(checked);
// name.setOnClickListener(checked);
}
}
private class DivisionHolder extends ViewHolder{
public TextView letter;
public DivisionHolder(View itemView) {
super(itemView);
letter = (TextView) itemView.findViewById(R.id.item_first_letter_text);
}
public void setBeans(ContactBean b){
letter.setText(b.getLetter());
}
}
public void checkAll(boolean isChecked){
//为局部刷新用
ArrayList<Integer> change = new ArrayList<Integer>();
int checkedSize = 0;
// int index = 0;
if(isChecked){
checkedSize = getCheckedSize();
int p = 0;
while(checkedSize<maxCheckSize){
if(beans.get(p).isChecked()!=isChecked&&beans.get(p).isPhone()){
beans.get(p).setChecked(isChecked);
checkedSize++;
change.add(p);
}
p++;
}
}else{
for(int i = 0;i<beans.size();i++){
if(beans.get(i).isChecked()!=isChecked){
beans.get(i).setChecked(isChecked);
change.add(i);
}
}
}
updateItems(change);
}
private void updateItems(ArrayList<Integer> change){
for(Integer integer : change){
notifyItemChanged(integer);
}
if(checkedPhoneListener!=null){
ContactBean[] returnBeans = new ContactBean[getCheckedSize()];
int index = 0;
for(ContactBean b : beans){
if(b.isChecked()){
returnBeans[index] = b;
index++;
}
}
checkedPhoneListener.onCheckedPhone(returnBeans);
}
}
private int getCheckedSize(){
int checkedSize = 0;
// for(int i = 0;i<beans.size();i++){
// if(beans.get(i).isChecked()==true){
// checkedSize++;
// }
// }
for(ContactBean b : beans){
if(b.isChecked())
checkedSize++;
}
return checkedSize;
}
private class OnItemChecked implements View.OnClickListener,OnCheckedChangeListener{
private final int p;
private Message msg;
public OnItemChecked(int p) {
super();
this.p = p;
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
msg = new Message();
msg.what = OnItemChecked;
msg.obj = this.p;
handler.sendMessage(msg);
}
@Override
public void onClick(View v) {
msg = new Message();
msg.what = OnItemChecked;
msg.obj = this.p;
handler.sendMessage(msg);
}
}
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case OnItemChecked:
//为局部刷新用
ArrayList<Integer> change = new ArrayList<Integer>();
int p = (Integer) msg.obj;
change.add(p);
if(beans.get(p).isChecked()){
beans.get(p).setChecked(false);
}else{
int size = getCheckedSize();
while(size>=10){
for(int i = 0;i<beans.size();i++){
if(beans.get(i).isChecked()){
beans.get(i).setChecked(false);
change.add(i);
size--;
break;
}
}
}
beans.get(p).setChecked(true);
}
updateItems(change);
break;
default:
break;
}
super.handleMessage(msg);
}
};
public interface OnCheckedPhoneListener{
public void onCheckedPhone(ContactBean[] checked);
}
public OnCheckedPhoneListener getCheckedPhoneListener() {
return checkedPhoneListener;
}
public void setCheckedPhoneListener(OnCheckedPhoneListener checkedPhoneListener) {
this.checkedPhoneListener = checkedPhoneListener;
}
}
| [
"[email protected]"
] | |
5ebc53e75f806106b52317e18562b98baa942992 | 51fa3cc281eee60058563920c3c9059e8a142e66 | /Java/src/testcases/CWE191_Integer_Underflow/s03/CWE191_Integer_Underflow__int_URLConnection_multiply_71b.java | 8246624687ddd2e54be912504f9030255a39f69e | [] | no_license | CU-0xff/CWE-Juliet-TestSuite-Java | 0b4846d6b283d91214fed2ab96dd78e0b68c945c | f616822e8cb65e4e5a321529aa28b79451702d30 | refs/heads/master | 2020-09-14T10:41:33.545462 | 2019-11-21T07:34:54 | 2019-11-21T07:34:54 | 223,105,798 | 1 | 4 | null | null | null | null | UTF-8 | Java | false | false | 2,346 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE191_Integer_Underflow__int_URLConnection_multiply_71b.java
Label Definition File: CWE191_Integer_Underflow__int.label.xml
Template File: sources-sinks-71b.tmpl.java
*/
/*
* @description
* CWE: 191 Integer Underflow
* BadSource: URLConnection Read data from a web server with URLConnection
* GoodSource: A hardcoded non-zero, non-min, non-max, even number
* Sinks: multiply
* GoodSink: Ensure there will not be an underflow before multiplying data by 2
* BadSink : If data is negative, multiply by 2, which can cause an underflow
* Flow Variant: 71 Data flow: data passed as an Object reference argument from one method to another in different classes in the same package
*
* */
package testcases.CWE191_Integer_Underflow.s03;
import testcasesupport.*;
import javax.servlet.http.*;
public class CWE191_Integer_Underflow__int_URLConnection_multiply_71b
{
public void badSink(Object dataObject ) throws Throwable
{
int data = (Integer)dataObject;
if(data < 0) /* ensure we won't have an overflow */
{
/* POTENTIAL FLAW: if (data * 2) < Integer.MIN_VALUE, this will underflow */
int result = (int)(data * 2);
IO.writeLine("result: " + result);
}
}
/* goodG2B() - use goodsource and badsink */
public void goodG2BSink(Object dataObject ) throws Throwable
{
int data = (Integer)dataObject;
if(data < 0) /* ensure we won't have an overflow */
{
/* POTENTIAL FLAW: if (data * 2) < Integer.MIN_VALUE, this will underflow */
int result = (int)(data * 2);
IO.writeLine("result: " + result);
}
}
/* goodB2G() - use badsource and goodsink */
public void goodB2GSink(Object dataObject ) throws Throwable
{
int data = (Integer)dataObject;
if(data < 0) /* ensure we won't have an overflow */
{
/* FIX: Add a check to prevent an underflow from occurring */
if (data > (Integer.MIN_VALUE/2))
{
int result = (int)(data * 2);
IO.writeLine("result: " + result);
}
else
{
IO.writeLine("data value is too small to perform multiplication.");
}
}
}
}
| [
"[email protected]"
] | |
6065efdeec19e00fc63eebb4eaf617da3683d699 | 3e4d6deecd6ad41b73cc10e1727236eb3e3b73a0 | /.mvn/wrapper/MavenWrapperDownloader.java | 2ef0760fec831e7dd32501bee01f5f68d2057c66 | [
"Apache-2.0"
] | permissive | Prodsgn/Harvest-Bank | 9e9f88ce6b838c0aff7dbd24d9c1ec5df08e6e80 | 8e4ac1bb2ab783aedeb8b41d6e091b25b091821e | refs/heads/master | 2023-07-03T23:50:51.325462 | 2021-08-09T10:55:54 | 2021-08-09T10:55:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,921 | java | /*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
| [
"[email protected]"
] | |
7c6160f43ceea3cdf713a0c23e639fafa94d5068 | ee110c1ca856b589b7bc5a8e620dffef041343a6 | /src/veiculos/veiculo.java | 454605858e3c0f54359cee7262fc8c76c3aa3f80 | [] | no_license | jhonnyulisilva/veiculo | 8f424ee4d928520e78095f4b95047a84318700b8 | 3d15c11e3705754954daed2a1001200fddff5ed5 | refs/heads/master | 2020-07-01T22:56:43.986873 | 2019-08-09T13:41:38 | 2019-08-09T13:41:38 | 201,331,610 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,212 | java | package veiculos;
public class veiculo {
protected static String marca;
protected static String modelo;
protected static String cor;
protected static int QtdTanque;
protected static String combus;
protected static boolean status;
public veiculo() {
}
public veiculo(String marca, String modelo, String cor, int qtdTanque, String combus) {
this.marca = marca;
this.modelo = modelo;
this.cor = cor;
this.QtdTanque = qtdTanque;
this.combus = combus;
this.status = false;
}
public String getMarca() {
return marca;
}
public void setMarca(String marca) {
this.marca = marca;
}
public String getModelo() {
return modelo;
}
public void setModelo(String modelo) {
this.modelo = modelo;
}
public String getCor() {
return cor;
}
public void setCor(String cor) {
this.cor = cor;
}
public static int getQtdTanque() {
return QtdTanque;
}
public void setQtdTanque(int qtdTanque) {
this.QtdTanque = qtdTanque;
}
public boolean getStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public String getCombus() {
return combus;
}
public void setCombus(String combus) {
this.combus = combus;
}
}
| [
"[email protected]"
] | |
5f6f93c2a1109c5f2de7f2cb6d8c91bdc6e034f4 | a77ad5eae0244622550e98e75d478d939af8e809 | /backend/PI5/src/main/java/dev/gabrielgrazziani/dto/ItemResponse.java | 9ec665f061f3947ae935dd75625d9f8dd2038d68 | [] | no_license | gabrielgrazziani/Projeto-Integrador-5 | b365a67fe93066867784d455f79c7b710bfbfb62 | b966631e83e8ada46e2a9d1f0f94fd84b7adcc5a | refs/heads/master | 2023-05-22T22:58:14.877155 | 2021-06-15T05:04:44 | 2021-06-15T05:04:44 | 348,739,905 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 525 | java | package dev.gabrielgrazziani.dto;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class ItemResponse {
private Long id;
private Long idOrdemServico;
private ServicoProdutoResponse servicoProduto;
private int quantidade;
@ApiModelProperty(notes = "Valor de uma unidade")
private BigDecimal valorUnidade;
public BigDecimal getSoma(){
return servicoProduto.getValorComercial().multiply(new BigDecimal(quantidade));
}
}
| [
"[email protected]"
] | |
15420be9a7da45e8f82a74cc673102f6638b9827 | e9affefd4e89b3c7e2064fee8833d7838c0e0abc | /aws-java-sdk-mgn/src/main/java/com/amazonaws/services/mgn/model/transform/UpdateReplicationConfigurationTemplateRequestProtocolMarshaller.java | f1c9e0eff3c5fde81718ec82478e9e99eca8cc11 | [
"Apache-2.0"
] | permissive | aws/aws-sdk-java | 2c6199b12b47345b5d3c50e425dabba56e279190 | bab987ab604575f41a76864f755f49386e3264b4 | refs/heads/master | 2023-08-29T10:49:07.379135 | 2023-08-28T21:05:55 | 2023-08-28T21:05:55 | 574,877 | 3,695 | 3,092 | Apache-2.0 | 2023-09-13T23:35:28 | 2010-03-22T23:34:58 | null | UTF-8 | Java | false | false | 2,985 | java | /*
* Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.mgn.model.transform;
import javax.annotation.Generated;
import com.amazonaws.SdkClientException;
import com.amazonaws.Request;
import com.amazonaws.http.HttpMethodName;
import com.amazonaws.services.mgn.model.*;
import com.amazonaws.transform.Marshaller;
import com.amazonaws.protocol.*;
import com.amazonaws.protocol.Protocol;
import com.amazonaws.annotation.SdkInternalApi;
/**
* UpdateReplicationConfigurationTemplateRequest Marshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class UpdateReplicationConfigurationTemplateRequestProtocolMarshaller implements
Marshaller<Request<UpdateReplicationConfigurationTemplateRequest>, UpdateReplicationConfigurationTemplateRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.REST_JSON)
.requestUri("/UpdateReplicationConfigurationTemplate").httpMethodName(HttpMethodName.POST).hasExplicitPayloadMember(false).hasPayloadMembers(true)
.serviceName("AWSmgn").build();
private final com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory;
public UpdateReplicationConfigurationTemplateRequestProtocolMarshaller(com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory) {
this.protocolFactory = protocolFactory;
}
public Request<UpdateReplicationConfigurationTemplateRequest> marshall(
UpdateReplicationConfigurationTemplateRequest updateReplicationConfigurationTemplateRequest) {
if (updateReplicationConfigurationTemplateRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
final ProtocolRequestMarshaller<UpdateReplicationConfigurationTemplateRequest> protocolMarshaller = protocolFactory.createProtocolMarshaller(
SDK_OPERATION_BINDING, updateReplicationConfigurationTemplateRequest);
protocolMarshaller.startMarshalling();
UpdateReplicationConfigurationTemplateRequestMarshaller.getInstance().marshall(updateReplicationConfigurationTemplateRequest, protocolMarshaller);
return protocolMarshaller.finishMarshalling();
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
}
}
| [
""
] | |
c6e192c650ad60cb553129caa722cec98e6f17ef | dfd8bbc187af8f8bc6529d5d5e213b416fd3ea29 | /src/test/java/org/terasology/dynamicCities/region/RegionEntitiesTest.java | c954ac81bf5a2cd28103bd8411b07900bc27a3d0 | [] | no_license | Terasology/DynamicCities | 862dd1428330033eee44f9a05b459b1e70078920 | 82c579876c804e205d305ab888cd1e2ff1b4cb9b | refs/heads/develop | 2023-07-20T00:08:33.194203 | 2022-06-07T20:52:33 | 2022-06-07T20:52:33 | 59,501,378 | 19 | 13 | null | 2022-12-18T13:53:18 | 2016-05-23T16:54:14 | Java | UTF-8 | Java | false | false | 4,370 | java | // Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.dynamicCities.region;
import org.joml.RoundingMode;
import org.joml.Vector2i;
import org.joml.Vector3f;
import org.joml.Vector3fc;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.integrationenvironment.jupiter.Dependencies;
import org.terasology.engine.integrationenvironment.jupiter.MTEExtension;
import org.terasology.engine.logic.location.LocationComponent;
import org.terasology.engine.registry.In;
import org.terasology.engine.world.chunks.Chunks;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("MteTest")
@ExtendWith({MockitoExtension.class, MTEExtension.class})
@Dependencies("DynamicCities")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class RegionEntitiesTest {
private static final int HALF_X = Chunks.SIZE_X / 2;
private static final int HALF_Z = Chunks.SIZE_Z / 2;
@In
public RegionEntityManager regionEntityManager;
private final Vector3fc[] pos = new Vector3f[] {
// These first four are used by the test for #getNearest, which resolves to
// the center of chunks. Something around the time of the JOML migration shifted
// that value down by one.
new Vector3f(HALF_X - 1, 0, HALF_Z - 1),
new Vector3f(HALF_X - 1, 0, -HALF_Z - 1),
new Vector3f(-HALF_X - 1, 0, HALF_Z - 1),
new Vector3f(-HALF_X - 1, 0, -HALF_Z - 1),
// …then why does this also have these locations that are at the corners of chunks
// instead of their centers?
new Vector3f(0, 0, 0),
new Vector3f(32, 0, 32),
new Vector3f(32, 0, -32),
new Vector3f(-32, 0, 32),
new Vector3f(-32, 0, -32),
new Vector3f(97, 0, -97)
};
private final EntityRef[] test = new EntityRef[pos.length];
@BeforeAll
public void setupEntityRefs() {
for (int i = 0; i < test.length; i++) {
test[i] = Mockito.mock(EntityRef.class, "mock EntityRef#" + i);
Mockito.when(test[i].getComponent(LocationComponent.class))
.thenReturn(new LocationComponent(pos[i]));
regionEntityManager.add(test[i]);
}
}
@Test
public void testSimpleGet() {
for (int i = 0; i < test.length; i++) {
Vector2i position = new Vector2i(pos[i].x(), pos[i].z(), RoundingMode.FLOOR);
assertEquals(test[i], regionEntityManager.get(position));
}
}
@ParameterizedTest(name = "{1}, {2} is nearest pos[{0}]")
@CsvSource({
"0, 21, 13",
"1, 14, -13",
"2, -22, 19",
"3, -13, -19"
})
public void testNearestGet(int index, int x, int y) {
assertEquals(test[index], regionEntityManager.getNearest(new Vector2i(x, y)));
}
@ParameterizedTest(name = "cell loaded at {0}, {1}")
@CsvSource({"0, 0", "16, 0", "0, -25"})
public void testCellsInRegionAreLoaded(int x, int y) {
assertTrue(regionEntityManager.cellIsLoaded(new Vector2i(x, y)));
}
@ParameterizedTest(name = "cell not loaded at {0}, {1}")
@CsvSource({"98, -124", "351, 234", "153, -134"})
public void testCellsOutsideRegionAreNotLoaded(int x, int y) {
assertFalse(regionEntityManager.cellIsLoaded(new Vector2i(x, y)));
}
@Disabled
@Test
public void testGetRegionsInCell() {
List<EntityRef> testList = Arrays.asList(test).subList(0, 5);
// FIXME: The method under test seems to be returning the correct values, but the list is
// out-of-order and contains duplicates.
assertEquals(testList, regionEntityManager.getRegionsInCell(new Vector2i(0, 0)));
}
}
| [
"[email protected]"
] | |
ccd45532a0897a08cc92c0a1045d5471c3466c9a | 0b1d57269ca8f9ae789c02b55d2f6b1c460b3be7 | /src/TermServer/src/main/generated/clamlBindingXSD/ModifiedBy.java | 8a98341e43932ed3492205a94d04bc7a2a8490d7 | [
"Apache-2.0"
] | permissive | FHDortmund/Termserver | b5e4110c39ec39aec0fee5ddb6dc3c5ada21cf3f | 716982054eec5dddabbdfdccaec25593e2544312 | refs/heads/master | 2021-01-15T15:47:13.578210 | 2018-05-14T13:15:00 | 2018-05-14T13:15:00 | 18,755,910 | 6 | 4 | null | 2014-07-28T08:55:59 | 2014-04-14T09:50:04 | null | UTF-8 | Java | false | false | 6,909 | java | //
// Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 generiert
// Siehe <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Änderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren.
// Generiert: 2018.04.09 um 11:53:09 AM CEST
//
package clamlBindingXSD;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* <p>Java-Klasse für anonymous complex type.
*
* <p>Das folgende Schemafragment gibt den erwarteten Content an, der in dieser Klasse enthalten ist.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{}Meta" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{}ValidModifierClass" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* <attribute name="position" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="variants" type="{http://www.w3.org/2001/XMLSchema}IDREFS" />
* <attribute name="all" default="true">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}NMTOKEN">
* <enumeration value="true"/>
* <enumeration value="false"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="code" use="required" type="{http://www.w3.org/2001/XMLSchema}NMTOKEN" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"meta",
"validModifierClass"
})
@XmlRootElement(name = "ModifiedBy")
public class ModifiedBy {
@XmlElement(name = "Meta")
protected List<Meta> meta;
@XmlElement(name = "ValidModifierClass")
protected List<ValidModifierClass> validModifierClass;
@XmlAttribute(name = "position")
protected String position;
@XmlAttribute(name = "variants")
@XmlIDREF
@XmlSchemaType(name = "IDREFS")
protected List<Object> variants;
@XmlAttribute(name = "all")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String all;
@XmlAttribute(name = "code", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NMTOKEN")
protected String code;
/**
* Gets the value of the meta property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the meta property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getMeta().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Meta }
*
*
*/
public List<Meta> getMeta() {
if (meta == null) {
meta = new ArrayList<Meta>();
}
return this.meta;
}
/**
* Gets the value of the validModifierClass property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the validModifierClass property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getValidModifierClass().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link ValidModifierClass }
*
*
*/
public List<ValidModifierClass> getValidModifierClass() {
if (validModifierClass == null) {
validModifierClass = new ArrayList<ValidModifierClass>();
}
return this.validModifierClass;
}
/**
* Ruft den Wert der position-Eigenschaft ab.
*
* @return
* possible object is
* {@link String }
*
*/
public String getPosition() {
return position;
}
/**
* Legt den Wert der position-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setPosition(String value) {
this.position = value;
}
/**
* Gets the value of the variants property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the variants property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getVariants().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Object }
*
*
*/
public List<Object> getVariants() {
if (variants == null) {
variants = new ArrayList<Object>();
}
return this.variants;
}
/**
* Ruft den Wert der all-Eigenschaft ab.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAll() {
if (all == null) {
return "true";
} else {
return all;
}
}
/**
* Legt den Wert der all-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAll(String value) {
this.all = value;
}
/**
* Ruft den Wert der code-Eigenschaft ab.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCode() {
return code;
}
/**
* Legt den Wert der code-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCode(String value) {
this.code = value;
}
}
| [
"[email protected]"
] | |
40d9646c82e7fef55659cfb60fef5a80387d5d12 | 46b785683218e71b6412e3147c4f6456992af8e8 | /app/src/main/java/edu/upenn/cis350/hwk2/data/Vowel.java | 62f3205c80555083c3c871a73701d60320058f3e | [] | no_license | chenhe95/KashayaPronunciationApp | fce606e0df3e432f00dba274dffb15b7526c7218 | 4b9f610df366936da637706249b46bb5274bf7db | refs/heads/master | 2020-09-18T12:11:02.483296 | 2016-09-10T17:27:07 | 2016-09-10T17:27:07 | 67,884,377 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,057 | java | package edu.upenn.cis350.hwk2.data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Vowel extends Sound {
public Vowel(int id, String name, String className, String form) {
super(id, name, className, form);
}
public static final Set<String> VOWELCLASS = new HashSet<>(Arrays.asList("high_front",
"mid_front", "low", "mid_back", "high_back"));
public static Vowel[] VOWELS = new Vowel[] {
new Vowel(1, "i", "high_front", "short"),
new Vowel(2, "i·", "high_front", "long"),
new Vowel(3, "e", "mid_front", "short"),
new Vowel(4, "e·", "mid_front", "long"),
new Vowel(5, "a", "low", "short"),
new Vowel(6, "a·", "low", "long"),
new Vowel(7, "o", "mid_back", "short"),
new Vowel(8, "o·", "mid_back", "long"),
new Vowel(9, "u", "high_back", "short"),
new Vowel(10, "u·", "high_back", "long")
};
// public static Vowel[] SHORT = new Vowel[] {
// new Vowel(1, "i"),
// new Vowel(3, "e"),
// new Vowel(5, "a"),
// new Vowel(7, "o"),
// new Vowel(9, "u")
// };
//
// public static Vowel[] LONG = new Vowel[] {
// new Vowel(2, "i·"),
// new Vowel(4, "e·"),
// new Vowel(6, "a·"),
// new Vowel(8, "o·"),
// new Vowel(10, "u·")
// };
public static boolean contains(Vowel[] vs, String name) {
for (int i = 0; i < vs.length; i++) {
if (vs[i].getName().equals(name)) {
return true;
}
}
return false;
}
public static List<Sound> getSoundsByClass(String className) {
return getSoundsByClass(className, VOWELS);
}
public static List<Sound> getSoundsByForm(String form) {
return getSoundsByForm(form, VOWELS);
}
}
| [
"[email protected]"
] | |
2d4783b4c876aea4c2a532b202b208f8e5354b03 | ae10be2acd490fd6e1650093d647ea6091181399 | /BPMConsoleApp/src/main/java/com/rhiscom/bpm/console/shared/model/rs/TaskWrapper.java | 763734d5e4d07c632e32a6ebb902fbc86c0da71e | [] | no_license | gschwarz/nickel | 10d2906a109132ce0e0a4b5f1b90e6b4617f92f9 | e6e5f704209716733699452edbd292dcf7c4165c | refs/heads/master | 2021-01-10T10:59:58.728630 | 2015-09-23T19:44:42 | 2015-09-23T19:44:42 | 43,008,358 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 246 | java | package com.rhiscom.bpm.console.shared.model.rs;
public class TaskWrapper {
private TaskDetailRS tasks;
public TaskDetailRS getTasks() {
return tasks;
}
public void setTasks(TaskDetailRS tasks) {
this.tasks = tasks;
}
}
| [
"[email protected]"
] | |
6f0b0112e0b403a90d46e27694760ab31823bab5 | c7c1c253b1320ab048456716da1769ff8329a9b7 | /app/src/main/java/com/mad41/tripreminder/trip_ui/TripModel.java | 7a32be4005f708938d411cab60eaf9eb760ff314 | [] | no_license | MarwaEbrahem/Trip_Reminder | 78d7b0ea450f3a132342e3bebd4278c9f2d2cede | 7280ac14ac8ce1d33dc6e1febf914a974892b9d5 | refs/heads/master | 2023-03-02T22:53:03.091102 | 2021-02-11T22:55:39 | 2021-02-11T22:55:39 | 334,614,211 | 0 | 0 | null | 2021-02-11T00:12:51 | 2021-01-31T09:06:30 | Java | UTF-8 | Java | false | false | 1,476 | java | package com.mad41.tripreminder.trip_ui;
import java.util.ArrayList;
public class TripModel {
private int id;
private String name;
private String startLoacation;
private String endLoacation;
private String time;
private String date;
private int status;
private boolean isRepeated;
private boolean isRound;
private ArrayList<String> myNotes;
public TripModel(String name, String startLoacation, String endLoacation,
String time, String date, int status, boolean isRepeated, boolean isRound) {
this.name = name;
this.startLoacation = startLoacation;
this.endLoacation = endLoacation;
this.time = time;
this.date = date;
this.status = status;
this.isRepeated = isRepeated;
this.isRound = isRound;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getStartLoacation() {
return startLoacation;
}
public String getEndLoacation() {
return endLoacation;
}
public String getTime() {
return time;
}
public String getDate() {
return date;
}
public int getStatus() {
return status;
}
public boolean isRepeated() {
return isRepeated;
}
public boolean isRound() {
return isRound;
}
public ArrayList<String> getMyNotes() {
return myNotes;
}
}
| [
"[email protected]"
] | |
2cac55ef1d355d1bb2b17456f1136307a39e7834 | d3a13c99c56c55e14c764ed4a276eb53e1014b90 | /src/main/java/forceman/ibank/entity/Client.java | 8cb84eb33995631be10fd307af35109cd324df40 | [] | no_license | ForceMan1/ibank1 | f78b0552f19bf6e989229e592c65dd78803a5639 | 0fed80411fc0cc6dd10684dece0ef2f3ead14a6f | refs/heads/master | 2021-01-11T02:46:16.332964 | 2016-11-01T12:02:59 | 2016-11-01T12:02:59 | 70,904,970 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,118 | java | package forceman.ibank.entity;
import javax.persistence.*;
/**
* Created by Igor on 20.09.2016.
*/
@Entity
@NamedQueries({
@NamedQuery(name = Client.QUERY_COUNT, query = "SELECT COUNT(c.id) FROM Client c"),
@NamedQuery(name = Client.QUERY_GET_CLIENTS, query = "SELECT c FROM Client c"),
@NamedQuery(name=Client.QUERY_DELETE_ALL_CLIENTS, query="DELETE FROM Client c")
})
public class Client {
public static final String QUERY_COUNT="countClients";
public static final String QUERY_GET_CLIENTS="getClients";
public static final String QUERY_DELETE_ALL_CLIENTS="deleteAllClients";
@GeneratedValue
@Id
private Long id;
@Basic(optional=false)
private String surname;
@Basic(optional=false)
private String name;
@Basic(optional=false)
private String login;
private String pass;
public Client(){}
public Client(String surname, String name, String login, String pass){
this.surname = surname;
this.name = name;
this.login = login;
this.pass = pass;
}
public void update(Client updClient) throws IllegalArgumentException {
if( !this.getId().equals( updClient.getId() ) )
throw new IllegalArgumentException("Primary keys of objects are not the same");
surname = updClient.getSurname();
name = updClient.getName();
login = updClient.getLogin();
pass = updClient.getPass();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
}
| [
"[email protected]"
] | |
d7acb7decf45393158a88056002f8c9238f44e19 | 34d88b26a5bbd92d947f04c099da1478420ec4fa | /HomeIOT_distributed_system/Mqtt_REST/Http__Server/src/main/java/com/arous/hda/TcpSocketServer.java | b3c6024509cdeffff788eca0b8c8165c225802c7 | [] | no_license | Arousde/hda_projects | 3e911e7e44a4a5161348d790fd0d04079def4f82 | d38a217210a8da8bd3517034dfc22d234ce1c3ff | refs/heads/main | 2023-01-12T01:19:13.971143 | 2020-11-12T22:27:38 | 2020-11-12T22:27:38 | 312,403,560 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,134 | java | package com.arous.hda;
import java.sql.Timestamp;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.logging.Logger;
import java.net.*;
// Apache
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import java.io.*;
public class TcpSocketServer {
private Logger log ;
/* Url from spark */
private interface sparkUrl{
String Turl = "http://localhost:1212/germany/temp";
String Hurl = "http://localhost:1212/germany/humidity";
String Purl = "http://localhost:1212/germany/pressure";
}
/* DATA for Apache*/
private ResponseHandler<String> handler ;
private CloseableHttpClient httpclient ;
private HttpGet method ;
private CloseableHttpResponse response ;
/*body data from Spark*/
private String temperature ;
private String pressure ;
private String humidity ;
/* DATA LISTS */
private ArrayList<String> Fensterzustend ;
private ArrayList<String> Temperatur ;
private ArrayList<String> DrehzahldesBadluefters ;
private ArrayList<String> Luftfeuchtigkeit ;
private String storedLine ;
/* MESSAGE FROM UDP */
private String message ;
private String line ;
private ArrayList<String> History ;
/* JAVA NET*/
private ServerSocket tcpServerSocket ;
private ServerSocket tcpServerSocketBrowser ;
private Socket connectionSocket ;
private Socket connectionSocketForHome ;
/* INPUT OUTPUT READER WRITER*/
private PrintWriter pw ;
private BufferedReader br ;
/* CONNECTS TO*/
private interface Destination {
String adr = "localhost" ;
int Port = 3341 ;
}
private interface BrowserDestination {
String adr = "localhost" ;
int Port = 3345 ;
}
public TcpSocketServer() {
this.log = Logger.getLogger(TcpSocketServer.class.getName());
try {
tcpServerSocket = new ServerSocket( Destination.Port);
log.info(new StringBuilder().append("Http Server for Home is listening on Port :").append(Destination.Port).toString());
tcpServerSocketBrowser = new ServerSocket( BrowserDestination.Port);
log.info(new StringBuilder().append("Http Server for Browser is listening on Port :").append(BrowserDestination.Port).toString());
} catch (IOException e) {
e.printStackTrace();
}
}
public void getSparkBodytemp() {
this.handler = new BasicResponseHandler();
// create an instance of HttpClient
this.httpclient = HttpClients.createDefault();
// crate methode instance
this.method = new HttpGet(sparkUrl.Turl);
// execute the response and get data from body
try {
this.response = httpclient.execute(this.method);
this.temperature = this.handler.handleResponse(this.response);
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void getSparkBodypress() {
this.handler = new BasicResponseHandler();
// create an instance of HttpClient
this.httpclient = HttpClients.createDefault();
// crate methode instance
this.method = new HttpGet(sparkUrl.Purl);
// execute the response and get data from body
try {
this.response = httpclient.execute(this.method);
this.pressure = this.handler.handleResponse(this.response);
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void getSparkBodyhumidity() {
this.handler = new BasicResponseHandler();
// create an instance of HttpClient
this.httpclient = HttpClients.createDefault();
// crate methode instance
this.method = new HttpGet(sparkUrl.Hurl);
// execute the response and get data from body
try {
this.response = httpclient.execute(this.method);
this.humidity = this.handler.handleResponse(this.response);
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public String runServerForHome() {
/*Open a new connection with Home and return the client */
try {
this.connectionSocketForHome = this.tcpServerSocket.accept();
} catch (IOException e) {
e.printStackTrace();
}
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(this.connectionSocketForHome.getInputStream()));
String line ;
this.message = "";
while ((line = br.readLine()) != null) {
StringBuilder strbuld = new StringBuilder();
strbuld.append(this.message).append(line);
this.message = strbuld.toString();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
this.connectionSocketForHome.close();
} catch (IOException e) {
e.printStackTrace();
}
return this.message;
}
public String concatMsgForStorageTpr(String ID , String Property) {
Timestamp t = new Timestamp(System.currentTimeMillis());
String msg = new String();
msg = msg.concat("SmartHome : "+ ID +" | Temperature : " + Property + " C " + " | Received : "+ t.toString());
return msg;
}
public String concatMsgForStoragefenstr(String ID , String Property) {
Timestamp t = new Timestamp(System.currentTimeMillis());
String msg = new String();
msg = msg.concat("SmartHome : " + ID + " | Fensterzustand : " + Property +" | Received : "+ t.toString());
return msg;
}
public String concatMsgForStoragedreh(String ID , String Property) {
Timestamp t = new Timestamp(System.currentTimeMillis());
String msg = new String();
msg = msg.concat("SmartHome : "+ ID + " | Drehzah " + Property + " | Received : "+ t.toString());
return msg;
}
public String concatMsgForStoragefeuch(String ID , String Property) {
Timestamp t = new Timestamp(System.currentTimeMillis());
String msg = new String();
msg = msg.concat("SmartHome : "+ ID + " | feuchtigkeit : " + Property + " | Received : "+ t.toString());
return msg;
}
public void storeData() {
message = runServerForHome();
/* GET JSON DATA FROM MESSAGE*/
jsonclass js = new jsonclass();
String id = js.get__ID(message);
String fenstr = js.get__Fensterzustend(message);
Long tpr = js.get__Temperatur(message);
Long drehzahl = js.get__DrehzahldesBadluefters(message);
Long feuch = js.get__Luftfeuchtigkeit(message);
String tprmsg = concatMsgForStorageTpr(id,tpr.toString());
this.Temperatur.add(tprmsg);
String feuchmsg = concatMsgForStoragefeuch(id,feuch.toString());
this.Luftfeuchtigkeit.add(feuchmsg);
String drehmsg = concatMsgForStoragedreh(id,drehzahl.toString());
this.DrehzahldesBadluefters.add(drehmsg);
String fnstrhmsg = concatMsgForStoragefenstr(id,fenstr);
this.Fensterzustend.add(fnstrhmsg);
String msg = js.messageToJsonObject(message);
History.add(msg);
/*PUBLISH MSG */
String pubMsg = js.DBmsg(message);
Publisher p = new Publisher();
p.run(pubMsg);
}
public void printTemp(PrintWriter pw) {
for (String s : this.Temperatur) {
pw.write("<h1 style=\"color:blue;text-align:center\">"+s+"</h1>");
pw.write("\r\n");
}
}
public void printFeucht(PrintWriter pw) {
for (String s : this.Luftfeuchtigkeit) {
pw.write("<h1 style=\"color:blue;text-align:center\">"+s+"</h1>");
pw.write("\r\n");
}
}
public void printFenster(PrintWriter pw) {
for (String s : this.Fensterzustend) {
pw.write("<h1 style=\"color:blue;text-align:center\">"+s+"</h1>");
pw.write("\r\n");
}
}
public void printLufter(PrintWriter pw) {
for (String s : this.DrehzahldesBadluefters) {
pw.write("<h1 style=\"color:blue;text-align:center\">"+s+"</h1>");
pw.write("\r\n");
}
}
public void printHistory(PrintWriter pw) {
for (String s : this.History) {
pw.write("\r\n");
pw.write("<h1 style=\"color:blue;text-align:center\">"+s+"</h1>");
pw.write("\r\n");
pw.write("<h3 style=\"color:red;text-align:center\">"+"********************************"+"</h3>");
pw.write("\r\n");
}
}
public void printsparktemp(PrintWriter pw) {
pw.write("\r\n");
pw.write("<h1 style=\"color:blue;text-align:center\">"+this.temperature+"</h1>");
pw.write("\r\n");
pw.write("<h3 style=\"color:red;text-align:center\">"+"********************************"+"</h3>");
pw.write("\r\n");
}
public void printsparkpress(PrintWriter pw) {
pw.write("\r\n");
pw.write("<h1 style=\"color:blue;text-align:center\">"+this.pressure+"</h1>");
pw.write("\r\n");
pw.write("<h3 style=\"color:red;text-align:center\">"+"********************************"+"</h3>");
pw.write("\r\n");
}
public void printsparkhumidity(PrintWriter pw) {
pw.write("\r\n");
pw.write("<h1 style=\"color:blue;text-align:center\">"+this.humidity+"</h1>");
pw.write("\r\n");
pw.write("<h3 style=\"color:red;text-align:center\">"+"********************************"+"</h3>");
pw.write("\r\n");
}
public void runlists() {
this.History = new ArrayList<>();
this.Temperatur = new ArrayList<>();
this.Luftfeuchtigkeit = new ArrayList<>();
this.DrehzahldesBadluefters = new ArrayList<>();
this.Fensterzustend = new ArrayList<>();
}
public void getTheHTTPGetNoun() {
br = null;
storedLine = "";
try {
br = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
line = br.readLine() ;
if(line !=null){
String[] arrayLine = line.split("\\s+");
line = "" ;
if (!arrayLine[1].equals("/favicon.ico")){
line = arrayLine[1];
}
if (!line.equals("")){
storedLine = line;
}
}
} catch (IOException e) {
e.printStackTrace();
}
/*try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}*/
}
public void connectToBrowser() {
try {
connectionSocket = tcpServerSocketBrowser.accept();
} catch (IOException e) {
e.printStackTrace();
}
}
synchronized public void run() {
runlists();
/* connect to the Home server in a separate thread*/
/* get the message and push it to the History Array*/
new Thread(new Runnable() {
@Override
public void run() {
while (true){
storeData();
}
}
}).start();
/*get data from spark*/
getSparkBodytemp();
getSparkBodypress();
getSparkBodyhumidity();
while (true) {
/*Open a new TCP connection and return the client Socket */
connectToBrowser();
/* Read the HTTP req and store the Get method noun in storedLine */
getTheHTTPGetNoun();
/* modify the socket output stream HTTP CONFORM*/
try {
this.pw = new PrintWriter(this.connectionSocket.getOutputStream());
this.pw.write(" HTTP/2.0 200 OK\r\n");
this.pw.write("Accept: text/plain, text/html, text/*\\r\\n");
this.pw.write("Host: localhost \r\n");
this.pw.write("\r\n");
this.pw.write("<TITLE>Smart Home Zentrale</TITLE>");
this.pw.write("<P>refresh to receive new Data</P>");
if (this.storedLine.equals("/temperature")){
printTemp(this.pw);
}
else if (this.storedLine.equals("/luftfeuchtigkeit")){
printFeucht(this.pw);
}
else if (this.storedLine.equals("/fensterzustand")){
printFenster(this.pw);
}
else if (this.storedLine.equals("/drehzahl")){
printLufter(this.pw);
}
else if (this.storedLine.equals("/history")){
printHistory(this.pw);
}
else if (this.storedLine.equals("/germany/temperature")){
printsparktemp(this.pw);
}
else if (this.storedLine.equals("/germany/pressure")){
printsparkpress(this.pw);
}
else if (this.storedLine.equals("/germany/humidity")){
printsparkhumidity(this.pw);
}
else {
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"temperature"+"</h1>");
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"luftfeuchtigkeit"+"</h1>");
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"fensterzustand"+"</h1>");
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"drehzahl"+"</h1>");
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"history"+"</h1>");
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"germany/temperature"+"</h1>");
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"germany/pressure"+"</h1>");
this.pw.write("<h1 style=\"color:blue;text-align:center\">"+"germany/humidity"+"</h1>");
}
this.pw.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
this.br.close();
} catch (IOException e) {
e.printStackTrace();
}
/* pw.close();
try {
connectionSocket.close();
} catch (IOException e) {
e.printStackTrace();
}*/
}
}
}
| [
"[email protected]"
] | |
36b5355292ffbf77b0c87a406e053bc11accd5d9 | 355143eeb91b845adbfc02b2c55afe949948dd18 | /VacuumCleaner/src/vacuumcleaner/EnvironmentInterface.java | 7fe57bb94e3dfe9260dcad720d1db07fde587b74 | [] | no_license | halhijje/Java-VacuumCleaner | 03b4e21db52cf721481eef1d2cc697620b44b14f | a012095573fa46a5868a9cb4c9efa53271774614 | refs/heads/master | 2021-07-19T20:54:48.262026 | 2017-10-28T15:28:40 | 2017-10-28T15:28:40 | 108,659,825 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 380 | java | package vacuumcleaner;
public interface EnvironmentInterface {
public int moveLeft();
public int moveRight();
public int moveUp();
public int moveDown();
public void suck(); // clean current cell
public boolean isDirty(); // is current cell dirty?
public int getScore(); // returns penalty score
public boolean isDirty(int i, int y);
} | [
"[email protected]"
] | |
12224b7099065254c020023748216fb946bee6ff | c12721a92eaaf10d325777e437540794c752caec | /src/model/Petugas.java | efac33d03421cad0efe9777508a0aa7ccf117e4d | [] | no_license | yuchandevi/TugasBesarPBO | 28753b144367fcf401a692afc99234ac3e159c27 | 8a2edd6250516fdb8844c7137a415ed471971698 | refs/heads/master | 2021-01-21T12:58:44.345781 | 2016-04-24T12:47:04 | 2016-04-24T12:47:04 | 52,098,758 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,268 | java | package model;
import javax.swing.JOptionPane;
public class Petugas extends Orang {
//attribuy
private Gudang G = null;
//konstruktor
public Petugas(String nama, long id){
super(nama,id);
}
public Petugas(){
}
//method
public void addBarang(String nama, int jumlah, Penyedia p){
for(int i=0 ; i < p.getDaftarBarang().size(); i++){ //perulangan dilakukan sebanyak jumlah barang yang ada di penyedia
if (p.getDaftarBarang().get(i).getNama_barang().equals(nama)){//p.getDaftarBarang()[i] adalah algoritma untuk mendapatkan barang dari indeks ke i dengan 3 atribut. bila di dot get nama artinya untuk mendapatkan nama dari suatu barang tersebut.
Barang b = new Barang();
b.setId(p.getDaftarBarang().get(i).getId()); // create objek barang, barang sudah di dapatkan dari penyedia
b.setNama_barang(p.getDaftarBarang().get(i).getNama_barang());
b.setJumlah_stok(p.getDaftarBarang().get(i).getJumlah_stok());
if (jumlah <= b.getJumlah_stok()) {
b.setJumlah_stok(jumlah); // mengeset jumlah barang yang akan di terima petugas dari penyedia. dengan menggunakan jumlah barang si petugas.
getG().addBarang(b);
break;
}else{
JOptionPane.showMessageDialog(null,"Jumlah Melebihi Kapasitas Penyedia !","Error !",0);
}
}
}
}
@Override
public void removeBarang(int Indeks){
getG().setKapasitas(getG().getKapasitas()+getG().getBarang(Indeks).getJumlah_stok());
getG().removeBarang(Indeks);
}
public void editBarang(String nama, int jumlah){
int stok_lama = 0;
int temp = 0;
Barang br = new Barang();
if (jumlah < getG().getKapasitas()){
for(int i=0 ; i< getG().getBarangGudang().size(); i++){
if (getG().getBarangGudang().get(i).getNama_barang().equals(nama)){
temp = i;
stok_lama = getG().getBarangGudang().get(i).getJumlah_stok();
getG().getBarangGudang().get(i).setJumlah_stok(jumlah);
br = getG().getBarangGudang().get(i);
if(br.getJumlah_stok() < stok_lama){
getG().setKapasitas(getG().getKapasitas()+(stok_lama-br.getJumlah_stok()));
} else if(br.getJumlah_stok() > stok_lama){
getG().setKapasitas(getG().getKapasitas()-(br.getJumlah_stok()-stok_lama));
}
JOptionPane.showMessageDialog(null,"Edit Barang Berhasil","Sukses !",1);
break;
}
}
}else{
JOptionPane.showMessageDialog(null,"Jumlah Melebihi Kapasitas Gudang, Kapasitas Gudang : "+getG().getKapasitas(),"Error !",0);
}
}
@Override
public Barang getBarang(int Indeks){
return(getG().getBarang(Indeks));
}
//setter getter
public Gudang getG() {
return G;
}
public void setG(Gudang G) {
this.G = G;
}
}
| [
"Windows@User"
] | Windows@User |
6c6c0dc53ed17976e9638a4794975bc1eaf3e595 | bb5df0135f44835aec761e539c5719d8d7a3012c | /src/test/java/io/bhupedra/spring5recipeapp/converters/UnitOfMeasureCommandToUnitOfMeasureTest.java | 46897a8d27e7847578ea0ee7e11b23d16c7207b4 | [] | no_license | Bhupendrapt5/spring5-recipe-app | 9909ec6ca552edb7ee9afa5faacdcaf01722187f | d08bc5dec71ec32549eefad870ce61679ee34109 | refs/heads/master | 2022-05-30T05:34:46.511272 | 2020-05-01T14:35:34 | 2020-05-01T14:35:34 | 254,805,222 | 0 | 1 | null | 2020-05-01T14:26:37 | 2020-04-11T06:12:57 | Java | UTF-8 | Java | false | false | 1,208 | java | package io.bhupedra.spring5recipeapp.converters;
import io.bhupedra.spring5recipeapp.commands.UnitOfMeasureCommand;
import io.bhupedra.spring5recipeapp.domain.UnitOfMeasure;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class UnitOfMeasureCommandToUnitOfMeasureTest {
public static Long ID = 1L;
public static String description = "description";
UnitOfMeasureCommandToUnitOfMeasure converter;
@BeforeEach
void setUp() {
converter = new UnitOfMeasureCommandToUnitOfMeasure();
}
@Test
void testNullObject() {
assertNull(converter.convert(null));
}
@Test
void testEmptyObject() {
assertNotNull(converter.convert(new UnitOfMeasureCommand()));
}
@Test
void convert() {
//given
UnitOfMeasureCommand command = new UnitOfMeasureCommand();
command.setId(ID);
command.setDescription(description);
//when
UnitOfMeasure uom = converter.convert(command);
//then
assertNotNull(uom);
assertEquals(ID, uom.getId());
assertEquals(description, uom.getDescription());
}
} | [
"[email protected]"
] | |
99292d27ccf3438fcbade57e551575ec35bfba03 | 038ee6b20cae51169a2ed4ed64a7b8e99b5cbaad | /schemaOrgImpl/src/org/kyojo/schemaorg/m3n4/core/itemAvailability/OUT_OF_STOCK.java | d3f0594e53dd041091d5ed15c50d56ed584b78c1 | [
"Apache-2.0"
] | permissive | nagaikenshin/schemaOrg | 3dec1626781913930da5585884e3484e0b525aea | 4c9d6d098a2741c2dc2a814f1c708ee55c36e9a8 | refs/heads/master | 2021-06-25T04:52:49.995840 | 2019-05-12T06:22:37 | 2019-05-12T06:22:37 | 134,319,974 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,433 | java | package org.kyojo.schemaorg.m3n4.core.itemAvailability;
import java.util.ArrayList;
import java.util.List;
import org.kyojo.schemaorg.SampleValue;
import org.kyojo.schemaorg.SimpleJsonBuilder;
import org.kyojo.schemaorg.m3n4.core.Container.AdditionalType;
import org.kyojo.schemaorg.m3n4.core.Container.AlternateName;
import org.kyojo.schemaorg.m3n4.core.Container.Description;
import org.kyojo.schemaorg.m3n4.core.Container.DisambiguatingDescription;
import org.kyojo.schemaorg.m3n4.core.Container.Identifier;
import org.kyojo.schemaorg.m3n4.core.Container.Image;
import org.kyojo.schemaorg.m3n4.core.Container.MainEntityOfPage;
import org.kyojo.schemaorg.m3n4.core.Container.Name;
import org.kyojo.schemaorg.m3n4.core.Container.NameFuzzy;
import org.kyojo.schemaorg.m3n4.core.Container.NameRuby;
import org.kyojo.schemaorg.m3n4.core.Container.PotentialAction;
import org.kyojo.schemaorg.m3n4.core.Container.SameAs;
import org.kyojo.schemaorg.m3n4.core.Container.Url;
import org.kyojo.schemaorg.m3n4.core.DataType;
import org.kyojo.schemaorg.m3n4.core.ItemAvailability;
import org.kyojo.schemaorg.m3n4.core.impl.NAME;
import org.kyojo.schemaorg.m3n4.core.impl.TEXT;
import org.kyojo.schemaorg.m3n4.meta.Container.SupersededBy;
import org.kyojo.schemaorg.m3n4.pending.Container.SubjectOf;
public class OUT_OF_STOCK implements ItemAvailability.OutOfStock {
private static final long serialVersionUID = 1L;
public Long seq;
public Long refSeq;
public String refAcr;
public java.util.Date createdAt;
public Long createdBy;
public java.util.Date updatedAt;
public Long updatedBy;
public java.util.Date expiredAt;
public Long expiredBy;
public AdditionalType additionalType;
public AlternateName alternateName;
public Description description;
public DisambiguatingDescription disambiguatingDescription;
public Identifier identifier;
public Image image;
public MainEntityOfPage mainEntityOfPage;
public Name name;
public NameFuzzy nameFuzzy;
public NameRuby nameRuby;
public PotentialAction potentialAction;
public SameAs sameAs;
public SubjectOf subjectOf;
public SupersededBy supersededBy;
public Url url;
public OUT_OF_STOCK() {
}
public OUT_OF_STOCK(Long seq) {
setSeq(seq);
}
public OUT_OF_STOCK(String string) {
setName(new NAME(new TEXT(string)));
}
@Override
public String getString() {
if(name == null) return null;
List<DataType.Text> textList = name.getTextList();
if(textList == null || textList.size() == 0 || textList.get(0) == null) {
return null;
} else {
return textList.get(0).getString();
}
}
@Override
public void setString(String string) {
if(name == null) name = new NAME();
List<DataType.Text> textList = name.getTextList();
if(textList == null) {
textList = new ArrayList<DataType.Text>();
name.setTextList(textList);
}
if(textList.size() == 0) {
textList.add(new TEXT(string));
} else {
textList.set(0, new TEXT(string));
}
}
public OUT_OF_STOCK(AdditionalType additionalType) {
setAdditionalType(additionalType);
}
@Override
public AdditionalType getAdditionalType() {
return additionalType;
}
@Override
public void setAdditionalType(AdditionalType additionalType) {
this.additionalType = additionalType;
}
public OUT_OF_STOCK(AlternateName alternateName) {
setAlternateName(alternateName);
}
@Override
public AlternateName getAlternateName() {
return alternateName;
}
@Override
public void setAlternateName(AlternateName alternateName) {
this.alternateName = alternateName;
}
public OUT_OF_STOCK(Description description) {
setDescription(description);
}
@Override
public Description getDescription() {
return description;
}
@Override
public void setDescription(Description description) {
this.description = description;
}
public OUT_OF_STOCK(DisambiguatingDescription disambiguatingDescription) {
setDisambiguatingDescription(disambiguatingDescription);
}
@Override
public DisambiguatingDescription getDisambiguatingDescription() {
return disambiguatingDescription;
}
@Override
public void setDisambiguatingDescription(DisambiguatingDescription disambiguatingDescription) {
this.disambiguatingDescription = disambiguatingDescription;
}
public OUT_OF_STOCK(Identifier identifier) {
setIdentifier(identifier);
}
@Override
public Identifier getIdentifier() {
return identifier;
}
@Override
public void setIdentifier(Identifier identifier) {
this.identifier = identifier;
}
public OUT_OF_STOCK(Image image) {
setImage(image);
}
@Override
public Image getImage() {
return image;
}
@Override
public void setImage(Image image) {
this.image = image;
}
public OUT_OF_STOCK(MainEntityOfPage mainEntityOfPage) {
setMainEntityOfPage(mainEntityOfPage);
}
@Override
public MainEntityOfPage getMainEntityOfPage() {
return mainEntityOfPage;
}
@Override
public void setMainEntityOfPage(MainEntityOfPage mainEntityOfPage) {
this.mainEntityOfPage = mainEntityOfPage;
}
public OUT_OF_STOCK(Name name) {
setName(name);
}
@Override
public Name getName() {
return name;
}
@Override
public void setName(Name name) {
this.name = name;
}
public OUT_OF_STOCK(NameFuzzy nameFuzzy) {
setNameFuzzy(nameFuzzy);
}
@Override
public NameFuzzy getNameFuzzy() {
return nameFuzzy;
}
@Override
public void setNameFuzzy(NameFuzzy nameFuzzy) {
this.nameFuzzy = nameFuzzy;
}
public OUT_OF_STOCK(NameRuby nameRuby) {
setNameRuby(nameRuby);
}
@Override
public NameRuby getNameRuby() {
return nameRuby;
}
@Override
public void setNameRuby(NameRuby nameRuby) {
this.nameRuby = nameRuby;
}
public OUT_OF_STOCK(PotentialAction potentialAction) {
setPotentialAction(potentialAction);
}
@Override
public PotentialAction getPotentialAction() {
return potentialAction;
}
@Override
public void setPotentialAction(PotentialAction potentialAction) {
this.potentialAction = potentialAction;
}
public OUT_OF_STOCK(SameAs sameAs) {
setSameAs(sameAs);
}
@Override
public SameAs getSameAs() {
return sameAs;
}
@Override
public void setSameAs(SameAs sameAs) {
this.sameAs = sameAs;
}
public OUT_OF_STOCK(SubjectOf subjectOf) {
setSubjectOf(subjectOf);
}
@Override
public SubjectOf getSubjectOf() {
return subjectOf;
}
@Override
public void setSubjectOf(SubjectOf subjectOf) {
this.subjectOf = subjectOf;
}
public OUT_OF_STOCK(SupersededBy supersededBy) {
setSupersededBy(supersededBy);
}
@Override
public SupersededBy getSupersededBy() {
return supersededBy;
}
@Override
public void setSupersededBy(SupersededBy supersededBy) {
this.supersededBy = supersededBy;
}
public OUT_OF_STOCK(Url url) {
setUrl(url);
}
@Override
public Url getUrl() {
return url;
}
@Override
public void setUrl(Url url) {
this.url = url;
}
public void copy(ItemAvailability.OutOfStock org) {
setSeq(org.getSeq());
setRefSeq(org.getRefSeq());
setRefAcr(org.getRefAcr());
setCreatedAt(org.getCreatedAt());
setCreatedBy(org.getCreatedBy());
setUpdatedAt(org.getUpdatedAt());
setUpdatedBy(org.getUpdatedBy());
setExpiredAt(org.getExpiredAt());
setExpiredBy(org.getExpiredBy());
setAdditionalType(org.getAdditionalType());
setAlternateName(org.getAlternateName());
setDescription(org.getDescription());
setDisambiguatingDescription(org.getDisambiguatingDescription());
setIdentifier(org.getIdentifier());
setImage(org.getImage());
setMainEntityOfPage(org.getMainEntityOfPage());
setName(org.getName());
setNameFuzzy(org.getNameFuzzy());
setNameRuby(org.getNameRuby());
setPotentialAction(org.getPotentialAction());
setSameAs(org.getSameAs());
setSubjectOf(org.getSubjectOf());
setSupersededBy(org.getSupersededBy());
setUrl(org.getUrl());
}
@Override
public String getNativeValue() {
return getString();
}
@Override
public String value() {
return ItemAvailability.OutOfStock.class.getAnnotation(SampleValue.class).value();
}
@Override
public Long getSeq() {
return seq;
}
@Override
public void setSeq(Long seq) {
this.seq = seq;
}
@Override
public Long getRefSeq() {
return refSeq;
}
@Override
public void setRefSeq(Long refSeq) {
this.refSeq = refSeq;
}
@Override
public String getRefAcr() {
return refAcr;
}
@Override
public void setRefAcr(String refAcr) {
this.refAcr = refAcr;
}
@Override
public java.util.Date getCreatedAt() {
return createdAt;
}
@Override
public void setCreatedAt(java.util.Date createdAt) {
this.createdAt = createdAt;
}
@Override
public Long getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
@Override
public java.util.Date getUpdatedAt() {
return updatedAt;
}
@Override
public void setUpdatedAt(java.util.Date updatedAt) {
this.updatedAt = updatedAt;
}
@Override
public Long getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(Long updatedBy) {
this.updatedBy = updatedBy;
}
@Override
public java.util.Date getExpiredAt() {
return expiredAt;
}
@Override
public void setExpiredAt(java.util.Date expiredAt) {
this.expiredAt = expiredAt;
}
@Override
public Long getExpiredBy() {
return expiredBy;
}
@Override
public void setExpiredBy(Long expiredBy) {
this.expiredBy = expiredBy;
}
@Override
public String toString() {
return SimpleJsonBuilder.toJson(this);
}
}
| [
"[email protected]"
] | |
575af143daac10e450d49165d6c101b19b0a20a1 | 2f7ed1053572b112bc5421c2ff0c46135eb3967e | /wane2/src/main/java/org/yescola/livraison/security/package-info.java | 5267e5f72e7b0e0eeb0f794d343a4662ae1b4a3f | [] | no_license | makhmadane/localisation | 4f52418d6eda81d92276b5031bb6f9bae740096d | 6b4550373e277ba801ca70745eea0eafc9b05914 | refs/heads/master | 2020-05-17T00:57:32.403408 | 2019-05-06T10:54:17 | 2019-05-06T10:54:17 | 183,410,885 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 82 | java | /**
* Spring Security configuration.
*/
package org.yescola.livraison.security;
| [
"[email protected]"
] | |
261a8fe362ea2fad2e4e9c4d80616134390a1c19 | 5c1288f54a1a68e436e02adc173f4789135bb812 | /Netty/src/main/java/netty/messages/ProtobufClient.java | 88e1c8108f2c5447026482af282f3013f229a143 | [] | no_license | picaqiu/Concurrent | 3c3a8ce8a752cbba244bd7ab84ff02febc0455c0 | 122b21b570c52dceca302555f60ffeb600441ed4 | refs/heads/develop | 2023-02-19T22:30:23.298324 | 2023-02-10T09:09:43 | 2023-02-10T09:09:43 | 219,666,205 | 0 | 0 | null | 2022-10-05T01:09:19 | 2019-11-05T05:40:58 | Java | UTF-8 | Java | false | false | 2,584 | java | package netty.messages;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ProtobufClient {
private final String host;
private final int port;
public ProtobufClient(String host, int port) {
this.host = host;
this.port = port;
}
public void sendMessage() {
Bootstrap b = new Bootstrap();
EventLoopGroup workers = new NioEventLoopGroup();
try {
b.group(workers);
b.channel(NioSocketChannel.class)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.option(ChannelOption.SO_KEEPALIVE, true)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new ProtobufVarint32LengthFieldPrepender())
.addLast(new ProtobufEncoder());
}
});
b.remoteAddress(host, port);
ChannelFuture f = b.connect();
f.addListener((ChannelFuture channelFuture) -> {
if (channelFuture.isSuccess()) {
log.info("客户端连接成功!");
} else {
log.info("客户端连接失败!");
}
});
f.sync();
Channel channel = f.channel();
for (int i = 0; i < 1000; i++) {
ProtoMessage.Message.Builder build = ProtoMessage.Message.newBuilder();
build.setId(i);
build.setContent("第" + i + "发送=》" + "Protobuf序列化消息");
channel.writeAndFlush(build.build());
}
//阻塞至连接断开
ChannelFuture close = f.channel().closeFuture();
close.sync();
} catch (Exception e) {
} finally {
workers.shutdownGracefully();
}
}
public static void main(String[] args) {
new ProtobufClient(ConfigConstants.SOCKET_SERVER_IP, ConfigConstants.SOCKET_SERVER_PORT).sendMessage();
}
}
| [
"[email protected]"
] | |
badaf0ee907e53979c20487d43a77e9dc3ed4ec6 | 4a4ec1ed1980cfeef63458335361278b1747233c | /flutter_1/android/app/src/main/java/com/shui/flutter_1/MainActivity.java | 621a64132979a22ea6ecd192693345fa012caa9a | [] | no_license | shuile/Flutter | 451903ee38ce5b819e315cc453e48de791422618 | 47f19f57b42b8a7f42c9153467feea23654fa9ef | refs/heads/master | 2020-07-04T09:50:15.463740 | 2020-04-06T12:23:54 | 2020-04-06T12:23:54 | 202,247,021 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 363 | java | package com.shui.flutter_1;
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
| [
"[email protected]"
] | |
e17914cebecf053059097321755c745936d11e79 | 4c5901b5fe27f4e8ee1305df1e5a8ae07cbb89aa | /Application/MyApplication/app/src/test/java/com/example/jho63/myapplication/ExampleUnitTest.java | a6e2af2074891b8294bd871b55e63803794ee226 | [] | no_license | NoGaBi/Geul_Lock | db8d8da844479b5a9b6f1445668752cc5e5b618d | 99017e2642469713a5226d9a2d4f851ac15a513b | refs/heads/master | 2021-06-04T02:25:27.337657 | 2020-03-09T14:00:20 | 2020-03-09T14:00:20 | 103,520,581 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 392 | java | package com.example.jho63.myapplication;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
acdfae039e656ed04d66605186ee1822b722de4a | 4a3ab0ac1d106330c556b80bd012d6648455993f | /kettle-ext/src/main/java/org/flhy/ext/job/steps/JobEntryWaitForSQL.java | b9ebde8cb609e5c43d2ee367ce1c65e356b45130 | [] | no_license | Maxcj/KettleWeb | 2e490e87103d14a069be4f1cf037d11423503d38 | 75be8f65584fe0880df6f6d637c72bcb1a66c4cd | refs/heads/master | 2022-12-21T06:56:34.756989 | 2022-02-05T03:03:57 | 2022-02-05T03:03:57 | 192,645,149 | 13 | 10 | null | 2022-12-16T02:43:00 | 2019-06-19T02:36:43 | JavaScript | UTF-8 | Java | false | false | 4,452 | java | package org.flhy.ext.job.steps;
import java.util.List;
import org.flhy.ext.App;
import org.flhy.ext.core.PropsUI;
import org.flhy.ext.job.step.AbstractJobEntry;
import org.flhy.ext.utils.JSONArray;
import org.flhy.ext.utils.JSONObject;
import org.flhy.ext.utils.StringEscapeHelper;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.ObjectLocationSpecificationMethod;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.logging.LogLevel;
import org.pentaho.di.job.entry.JobEntryInterface;
import org.pentaho.di.repository.ObjectId;
import org.pentaho.di.repository.Repository;
import org.pentaho.di.repository.RepositoryDirectoryInterface;
import org.pentaho.di.repository.RepositoryElementMetaInterface;
import org.pentaho.di.repository.RepositoryObject;
import org.pentaho.di.repository.RepositoryObjectType;
import org.pentaho.di.repository.StringObjectId;
import org.pentaho.metastore.api.IMetaStore;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.mxgraph.model.mxCell;
import com.mxgraph.util.mxUtils;
@Component("WAIT_FOR_SQL")
@Scope("prototype")
public class JobEntryWaitForSQL extends AbstractJobEntry {
@Override
public void decode(JobEntryInterface jobEntry, mxCell cell, List<DatabaseMeta> databases, IMetaStore metaStore) throws Exception {
org.pentaho.di.job.entries.waitforsql.JobEntryWaitForSQL jobEntryWaitForSQL = (org.pentaho.di.job.entries.waitforsql.JobEntryWaitForSQL) jobEntry;
//一般---服务器设置
jobEntryWaitForSQL.customSQL=(StringEscapeHelper.decode(cell.getAttribute("customSQL")));
String con = cell.getAttribute( "connection" );
jobEntryWaitForSQL.setDatabase(DatabaseMeta.findDatabase( databases, con ));
jobEntryWaitForSQL.schemaname=cell.getAttribute("schemaname");
jobEntryWaitForSQL.tablename=(cell.getAttribute("tablename"));
jobEntryWaitForSQL.successCondition= jobEntryWaitForSQL.getSuccessConditionByDesc(cell.getAttribute( "successCondition" ));
jobEntryWaitForSQL.rowsCountValue=Const.NVL(cell.getAttribute("rowsCountValue"), "0");
jobEntryWaitForSQL.setMaximumTimeout(cell.getAttribute("maximumTimeout"));
jobEntryWaitForSQL.setCheckCycleTime(cell.getAttribute("checkCycleTime"));
jobEntryWaitForSQL.setSuccessOnTimeout("Y".equalsIgnoreCase(cell.getAttribute("successOnTimeout")));
jobEntryWaitForSQL.iscustomSQL=("Y".equalsIgnoreCase(cell.getAttribute("iscustomSQL")));
jobEntryWaitForSQL.isUseVars=("Y".equalsIgnoreCase(cell.getAttribute("isUseVars")));
jobEntryWaitForSQL.isClearResultList=("Y".equalsIgnoreCase(cell.getAttribute("isClearResultList")));
jobEntryWaitForSQL.isAddRowsResult=("Y".equalsIgnoreCase(cell.getAttribute("isAddRowsResult")));
}
@Override
public Element encode(JobEntryInterface jobEntry) throws Exception {
org.pentaho.di.job.entries.waitforsql.JobEntryWaitForSQL jobEntryWaitForSQL = (org.pentaho.di.job.entries.waitforsql.JobEntryWaitForSQL) jobEntry;
String[] successConditionsCode = org.pentaho.di.job.entries.evaluatetablecontent.JobEntryEvalTableContent.successConditionsCode;
Document doc = mxUtils.createDocument();
Element e = doc.createElement(PropsUI.JOB_JOBENTRY_NAME);
//一般---服务器设置
e.setAttribute("customSQL", StringEscapeHelper.encode(jobEntryWaitForSQL.customSQL));
e.setAttribute("connection", jobEntryWaitForSQL.getDatabase() == null ? "" : jobEntryWaitForSQL.getDatabase().getName());
e.setAttribute("schemaname", jobEntryWaitForSQL.schemaname );
e.setAttribute("tablename", jobEntryWaitForSQL.tablename);
e.setAttribute("successCondition", successConditionsCode[jobEntryWaitForSQL.getSuccessCondition()]);
e.setAttribute("rowsCountValue", jobEntryWaitForSQL.rowsCountValue );
e.setAttribute("maximumTimeout", jobEntryWaitForSQL.getMaximumTimeout() );
e.setAttribute("checkCycleTime", jobEntryWaitForSQL.getCheckCycleTime() );
e.setAttribute("successOnTimeout", jobEntryWaitForSQL.isSuccessOnTimeout() ? "Y" : "N");
e.setAttribute("iscustomSQL", jobEntryWaitForSQL.iscustomSQL ? "Y" : "N");
e.setAttribute("isUseVars", jobEntryWaitForSQL.isUseVars ? "Y" : "N");
e.setAttribute("isClearResultList", jobEntryWaitForSQL.isClearResultList ? "Y" : "N");
e.setAttribute("isAddRowsResult", jobEntryWaitForSQL.isAddRowsResult ? "Y" : "N");
return e;
}
}
| [
"[email protected]"
] | |
f7748a64407b2f0e682fed94cab7a0ece760245b | c03af6e9be47c81d50f1e08b67c7431a1c35ec93 | /src/com/gs/mapper/PomsConsumeEnergyTerminalRefMapper.java | 8608f024a451fbf6a21f1e5d0d9e60630beaefda | [] | no_license | song2gao/emcc-new | 2bcb9810ec68c8d0be4dc5e161d45c8bf74a0fdf | 1845449fcd5c8f9354106a11028b2c0487008ff1 | refs/heads/master | 2020-07-20T05:32:06.474156 | 2019-09-05T14:16:09 | 2019-09-05T14:16:09 | 206,580,474 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 790 | java | package com.gs.mapper;
import org.apache.ibatis.annotations.Param;
import com.gs.domain.PomsConsumeEnergyTerminalRef;
public interface PomsConsumeEnergyTerminalRefMapper {
int deleteByPrimaryKey(String id);
int insert(PomsConsumeEnergyTerminalRef record);
int insertSelective(PomsConsumeEnergyTerminalRef record);
PomsConsumeEnergyTerminalRef selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(PomsConsumeEnergyTerminalRef record);
int updateByPrimaryKey(PomsConsumeEnergyTerminalRef record);
/**
* 根据分项类型和分项编码查找表计
* @param type 分项类型
* @param code 分项编码
* @return 表计数组
*/
String[] selectCtdsByTypeAndCode(@Param("type")String type,@Param("code")String code);
} | [
"[email protected]"
] | |
f97f8244f41e53b1609d7f13f6b8b6e125438b7c | e9124854d2bb3a40f6642858f3777e89a88b1d54 | /custom/toint/tointbackoffice/src/org/tointbackoffice/YacceleratorbackofficeStandalone.java | e03414ba464533f3787bbfe6136a444a51bfdd52 | [] | no_license | Prashanth-techouts/Toint | 9bcba94fd0422f20131c24cd9e0ec19e789941d6 | dbd466fae6303a6c796ffd52f169119a4a7ee134 | refs/heads/master | 2023-09-03T02:20:49.827317 | 2021-10-22T10:48:30 | 2021-10-22T10:48:30 | 419,990,956 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,582 | java | /*
* Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
*/
package org.tointbackoffice;
import de.hybris.platform.core.Registry;
import de.hybris.platform.jalo.JaloSession;
import de.hybris.platform.util.RedeployUtilities;
import de.hybris.platform.util.Utilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Demonstration of how to write a standalone application that can be run directly from within eclipse or from the
* commandline.<br>
* To run this from commandline, just use the following command:<br>
* <code>
* java -jar bootstrap/bin/ybootstrap.jar "new org.tointbackoffice.YacceleratorbackofficeStandalone().run();"
* </code> From eclipse, just run as Java Application. Note that you maybe need to add all other projects like
* ext-commerce, ext-pim to the Launch configuration classpath.
*/
public class YacceleratorbackofficeStandalone
{
private static final Logger LOG = LoggerFactory.getLogger(YacceleratorbackofficeStandalone.class);
/**
* Main class to be able to run it directly as a java program.
*
* @param args
* the arguments from commandline
*/
public static void main(final String[] args)
{
new YacceleratorbackofficeStandalone().run();
}
public void run()
{
Registry.activateStandaloneMode();
Registry.activateMasterTenant();
final JaloSession jaloSession = JaloSession.getCurrentSession();
LOG.info("Session ID: {}", jaloSession.getSessionID());
LOG.info("User: {}", jaloSession.getUser());
Utilities.printAppInfo();
RedeployUtilities.shutdown();
}
}
| [
"[email protected]"
] | |
6e854b5ea2ed7d8ddf07f9cef10185aa05918136 | e6a3755aa92514ae907b093c219d1fb2e1885866 | /src/main/java/com/udemy/backendninja/entity/Contact.java | fd8d44f7207b50393dea0d27e6227a8c9dc204e3 | [] | no_license | LutiJimenez/usuarios | b366c476cbc70a85284ac7e545e6ec96d01a5e85 | 34a75612fe7415ae0e94c8c847c77df8c16f07cb | refs/heads/master | 2022-12-13T03:36:17.102441 | 2020-09-18T11:34:36 | 2020-09-18T11:34:36 | 105,628,327 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,475 | java | package com.udemy.backendninja.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "contact")
public class Contact {
@Id
@GeneratedValue
@Column(name = "id")
private int id;
@Column(name = "firstname")
private String firstname;
@Column(name = "lastname")
private String lastname;
@Column(name = "telephone")
private String telephone;
@Column(name = "city")
private String city;
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public Contact(int id, String firstname, String lastname, String telephone,
String city) {
super();
this.id = id;
this.firstname = firstname;
this.lastname = lastname;
this.telephone = telephone;
this.city = city;
}
public Contact() {
}
}
| [
"[email protected]"
] | |
6b7ebc27166b26a09aaec7fa2b3a8558860fee3d | eadbd6ba5a2d5c960ffa9788f5f7e79eeb98384d | /src/com/google/android/m4b/maps/bv/d.java | 9870850780b3e00335c848e589446f6d2868c5d3 | [] | no_license | marcoucou/com.tinder | 37edc3b9fb22496258f3a8670e6349ce5b1d8993 | c68f08f7cacf76bf7f103016754eb87b1c0ac30d | refs/heads/master | 2022-04-18T23:01:15.638983 | 2020-04-14T18:04:10 | 2020-04-14T18:04:10 | 255,685,521 | 0 | 0 | null | 2020-04-14T18:00:06 | 2020-04-14T18:00:05 | null | UTF-8 | Java | false | false | 1,815 | java | package com.google.android.m4b.maps.bv;
import java.lang.reflect.Field;
public final class d<T>
extends b.a
{
private final T a;
private d(T paramT)
{
a = paramT;
}
public static <T> b a(T paramT)
{
return new d(paramT);
}
public static <T> T a(b paramb)
{
if ((paramb instanceof d)) {
return (T)a;
}
paramb = paramb.asBinder();
Object localObject = paramb.getClass().getDeclaredFields();
if (localObject.length == 1)
{
localObject = localObject[0];
if (!((Field)localObject).isAccessible())
{
((Field)localObject).setAccessible(true);
try
{
paramb = ((Field)localObject).get(paramb);
return paramb;
}
catch (NullPointerException paramb)
{
throw new IllegalArgumentException("Binder object is null.", paramb);
}
catch (IllegalArgumentException paramb)
{
throw new IllegalArgumentException("remoteBinder is the wrong class.", paramb);
}
catch (IllegalAccessException paramb)
{
throw new IllegalArgumentException("Could not access the field in remoteBinder.", paramb);
}
}
throw new IllegalArgumentException("The concrete class implementing IObjectWrapper must have exactly one declared *private* field for the wrapped object. Preferably, this is an instance of the ObjectWrapper<T> class.");
}
throw new IllegalArgumentException("The concrete class implementing IObjectWrapper must have exactly *one* declared private field for the wrapped object. Preferably, this is an instance of the ObjectWrapper<T> class.");
}
}
/* Location:
* Qualified Name: com.google.android.m4b.maps.bv.d
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"[email protected]"
] | |
51478e5ae2040f5cd27e433733da4b5d70797525 | 162c17e9a0f8dd23f4e9dbc11e55939f121381fb | /src/main/java/com/lex418/springdatajpa/dao/PeopleManagementDao.java | ac8ec019e3fca1948430b98554ccacba55e9ac2e | [] | no_license | rakesh418/spring-data-jpa | 3d72bc7018abfbce0d8f9ec724958fd43358df37 | 3b36c13e5bb39f4a690c6abbdb60f5e7f1de9353 | refs/heads/master | 2022-12-18T10:14:27.155106 | 2020-09-27T07:07:01 | 2020-09-27T07:07:01 | 295,728,279 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 351 | java | package com.lex418.springdatajpa.dao;
import com.lex418.springdatajpa.entities.Person;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.Repository;
import java.util.List;
public interface PeopleManagementDao extends CrudRepository<Person,Integer> {
Person findByLastName(String lastName);
}
| [
"[email protected]"
] | |
4fc92e5b106e812a3100b9709323c78257dc91e4 | f21333c47b556991951ca2026bc897d7c624d4d0 | /src/main/java/com/framework/report/ReportTestManager.java | ae8499cb999bad925ca102014dcc62cf2c289373 | [] | no_license | prachiverma/seleniumApi | 13458ce2538e485a5374c8bdce177a87d54167b9 | 0337037f318159368db85170f389df5c6557b387 | refs/heads/main | 2023-03-20T03:56:03.983785 | 2021-03-14T08:56:39 | 2021-03-14T08:56:39 | 347,585,347 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,115 | java | package com.framework.report;
import java.util.HashMap;
import java.util.Map;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;
public class ReportTestManager {
static Map<Integer, ExtentTest> extentTestMap = new HashMap<Integer, ExtentTest>();
static ExtentReports extent = ReportManager.getInstance();
public static synchronized ExtentTest getTest() {
return (ExtentTest) extentTestMap.get((int) (long) (Thread.currentThread().getId()));
}
public static synchronized void endTest() {
//extent.endTest((ExtentTest) extentTestMap.get((int) (long) (Thread.currentThread().getId())));
}
public static synchronized ExtentTest startTest(String testName, String className) {
ExtentTest test = extent.createTest(testName, className);
extentTestMap.put((int) (long) (Thread.currentThread().getId()), test);
test.assignAuthor("Prachi");
test.assignCategory(className);
return test;
}
public static synchronized void logText(String message) {
getTest().log(Status.PASS, message);
}
}
| [
"[email protected]"
] | |
1a18a0d26d2809d301202389163ee2683db4cd0e | f82c3317d83f6fa3108141729a9756b85c13a397 | /config-server-git/src/test/java/com/winter/ConfigServerGitApplicationTests.java | 975b1a006ca57a58fb2d07a0cd2a01dc29ddde23 | [] | no_license | WinterChenS/spring-cloud | bc7c09a50560d3c506c78e6cd18e7a6c8f630d8a | 362e08868cf651ea21a91da94e888cdf42a5b4f5 | refs/heads/master | 2021-05-15T17:24:27.293984 | 2017-10-19T06:36:16 | 2017-10-19T06:36:16 | 107,507,515 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 336 | java | package com.winter;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ConfigServerGitApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
f646791ee6f74a593a2a3bcaa9dec2227c0c2af0 | f577abaa6e6a9ceaf0a663a9a6a5d2ff96c6d5f4 | /Biz-Resume/src/main/java/com/smartbean/enums/DegreeEnum.java | 2409752ca58cd45e1aa5f709b8123bfac95be13a | [] | no_license | breakfastTeam/resume | 704af6e07ac0383f21380a46bdf8ec6bae70768c | b3191e8d482013e81f23bbabe59550e19a2bfe75 | refs/heads/master | 2021-01-20T12:15:55.892157 | 2017-09-11T09:13:48 | 2017-09-11T09:13:48 | 101,705,362 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,053 | java | package com.smartbean.enums;
/**
* Created by felix on 8/28/17.
*/
public enum DegreeEnum {
JUNIOR_COLLEGE("junior_college", "1", "高中/中专"),
HIGH_SCHOOL("high_school", "2", "高中"),
UNDERGRADUATE("undergraduate", "3", "本科"),
MASTER("master", "4", "研究生"),
DOCTOR("doctor", "5", "博士"),
MBA("mba", "6", "MBA");
/**
* 返回结果枚举构造方法
*
* @param code 结果码
* @param dbValue 数据库存入短整型值
* @param description 结果描述
*/
DegreeEnum(String code, String dbValue, String description) {
this.code = code;
this.dbValue = dbValue;
this.description = description;
}
/**
* code
*/
private String code;
/**
* 数据库保存的对应值
*/
private String dbValue;
/**
* 描述
*/
private String description;
/**
*
* @return 代码
*/
public String getCode() {
return code;
}
/**
* 获取数据中存入的对应短整型值
* @return
*/
public String getDBValue() {
return dbValue;
}
/**
* @return 描述
*/
public String getDescription() {
return description;
}
/**
* 通过code得到返回结果对象
*
* @param code 结果码
* @return 结果枚举对象
*/
public static DegreeEnum get(String code) {
if ("".equals(code) || code == null) {
throw new RuntimeException("编码不存在!");
}
DegreeEnum[] list = values();
for (DegreeEnum customerType : list) {
if (code.equals(customerType.getCode().toString())) {
return customerType;
}
}
return null;
}
@Override
public String toString() {
return "JobStateEnum{" +
"code=" + code +
", dbValue=" + dbValue +
", description='" + description + '\'' +
'}';
}
} | [
"[email protected]"
] | |
8de26de15a6d00895afc2f0e6eff7318a7d011e4 | d0f9452387c43ae8278307a889517c33e24d3389 | /clients/src/main/java/com/vmware/thinapp/common/workpool/dto/Win8OsType.java | 1999232e735a2e6ed2b466c7757a1c5bbd7fa83c | [
"Apache-2.0"
] | permissive | pcrane70/thinapp_factory | 38ed7085c208eddf853a28b587f70cc42a0488fb | 5910839b29bf79e6565291bff51a555de0795176 | refs/heads/master | 2020-08-15T12:11:36.531525 | 2019-10-15T16:02:29 | 2019-10-15T16:02:29 | 215,339,895 | 0 | 0 | NOASSERTION | 2019-10-15T16:02:30 | 2019-10-15T16:00:46 | null | UTF-8 | Java | false | false | 1,802 | java | /* ***********************************************************************
* VMware ThinApp Factory
* Copyright (c) 2009-2013 VMware, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ***********************************************************************/
package com.vmware.thinapp.common.workpool.dto;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
* This class indicates an OSType for Win 8.
*/
public class Win8OsType extends OsType {
/** The variants for Win8. */
public enum Variant {
professional,
enterprise,
ultimate
}
private Variant variant;
public Win8OsType() {
/* default constructor */
}
public Win8OsType(Variant variant) {
this.variant = variant;
}
/**
* @return the variant
*/
public Variant getVariant() {
return variant;
}
/**
* @param variant the variant to set
*/
public void setVariant(Variant variant) {
this.variant = variant;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
@Override
public String getOsVariantName() {
return getVariant().name();
}
}
| [
"[email protected]"
] | |
3aea71209df7d1a851c362ef9776aa146e446358 | 9135773786a8ee9f6ff6d26fc0c585aa7a837bd4 | /src/main/java/dev/sgp/web/EditerCollaborateurController.java | d8159fe669b54d106c5eb429b5d6349b3b5bf357 | [] | no_license | flodu13/exojavaservletjsp | 94db84a7ee3a5cca31ec063ed4d6104f213f7721 | b81deb88869c45a244a6d9bd09ca291a197045ac | refs/heads/master | 2021-07-04T19:33:51.032019 | 2019-06-03T13:13:51 | 2019-06-03T13:13:51 | 190,006,196 | 0 | 0 | null | 2020-10-13T13:39:03 | 2019-06-03T13:00:53 | JavaScript | UTF-8 | Java | false | false | 823 | java | package dev.sgp.web;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class EditerCollaborateurController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException {
String matriculeParam = req.getParameter("matricule");
resp.setContentType("text/html");
if (matriculeParam==null) {
System.out.println("Un matricule est attendu");
resp.sendError(400, "le matricule est attendu");
} else {
resp.setStatus(200);
resp.getWriter().write("<h1>Edition de collaborateur</h1>"
+ "<p>Matricule : " + matriculeParam + "</p>");
}
}
}
| [
"[email protected]"
] | |
9db4afa65f811dbd1e9d652047d93756333fae4c | 4d4ed5825778e4c5581f8b140251766d9560b752 | /src/main/java/com/hanhang/mall/service/impl/UmsAdminServiceImpl.java | b5175a5e91e47416aac1d28847ff10b8ada32cc7 | [] | no_license | hanhang6/mall_study | 07795b5224e195d3c50f171334a38f8a9056221e | ccf72413acc8afc5c2215d6d2c586fe15ef9c674 | refs/heads/master | 2023-04-01T00:35:55.235780 | 2021-03-29T07:13:35 | 2021-03-29T07:13:35 | 352,225,241 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,935 | java | package com.hanhang.mall.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hanhang.mall.common.utils.JwtTokenUtil;
import com.hanhang.mall.dao.UmsAdminMapper;
import com.hanhang.mall.entity.UmsAdmin;
import com.hanhang.mall.entity.UmsPermission;
import com.hanhang.mall.service.UmsAdminRoleRelationService;
import com.hanhang.mall.service.UmsAdminService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> implements UmsAdminService {
private static final Logger LOGGER = LoggerFactory.getLogger(UmsAdminServiceImpl.class);
@Resource
private UserDetailsService userDetailsService;
@Resource
private PasswordEncoder passwordEncoder;
@Resource
private JwtTokenUtil jwtTokenUtil;
@Resource
private UmsAdminRoleRelationService roleRelationService;
@Resource
private UmsAdminMapper umsAdminDao;
@Override
public UmsAdmin getAdminByUsername(String username) {
QueryWrapper<UmsAdmin> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("username",username);
List<UmsAdmin> admins = umsAdminDao.selectList(queryWrapper);
if (CollectionUtils.isNotEmpty(admins)){
return admins.get(0);
}
return null;
}
@Override
public UmsAdmin register(UmsAdmin umsAdminParam) {
UmsAdmin umsAdmin = new UmsAdmin();
BeanUtils.copyProperties(umsAdminParam, umsAdmin);
umsAdmin.setCreateTime(new Date());
umsAdmin.setStatus(1);
//查询是否有相同用户名的用户
QueryWrapper<UmsAdmin> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("username",umsAdmin.getUsername());
List<UmsAdmin> umsAdminList = umsAdminDao.selectList(queryWrapper);
if (umsAdminList.size() > 0) {
return null;
}
//将密码进行加密操作
String encodePassword = passwordEncoder.encode(umsAdmin.getPassword());
umsAdmin.setPassword(encodePassword);
umsAdminDao.insert(umsAdmin);
return umsAdmin;
}
@Override
public String login(String username, String password) {
String token = null;
try {
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
if (!passwordEncoder.matches(password, userDetails.getPassword())) {
throw new BadCredentialsException("密码不正确");
}
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
token = jwtTokenUtil.generateToken(userDetails);
} catch (AuthenticationException e) {
LOGGER.warn("登录异常:{}", e.getMessage());
}
return token;
}
@Override
public List<UmsPermission> getPermissionList(Long adminId) {
return roleRelationService.getPermissionList(adminId);
}
}
| [
"[email protected]"
] | |
352f9b9e88de47f5700f0c27c353235b8743b6b9 | 068a4313d8f141ee88985a1d1127c2ed4e54124c | /src/spaceinvade/the/destruction/modelo/player.java | b98721174487c866e5c1caaa523e48b9139f4967 | [] | no_license | davidqpinho/Space-Invader-The-Destruction | f410f3628c44cab2328146741e0a10525c896a04 | 4e179b93347d3a6939a08caae6b86a936f93fae8 | refs/heads/master | 2020-04-29T00:14:51.386560 | 2019-03-19T11:13:58 | 2019-03-19T11:13:58 | 175,686,781 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,972 | java | package spaceinvade.the.destruction.modelo;
/**
*
* @author Davidqpinho
*/
public class player extends Personagem{
/*
*aqui é aonde sera definido o icon, e o metodo move
*/
private static final int LARGURA = 43;
private static final int ALTURA = 47;
private boolean leftKey = false;
private boolean rightKey = false;
private boolean upkey = false;
private boolean downkey = false;
private boolean spacekey = false;
private int playerExplosion;
private int scorePt = 0;
public player(int x, int y)
{
super(x,y,LARGURA,ALTURA);
}
public void getKey( boolean leftKey,
boolean rightKey,
boolean upkey,
boolean downkey,
boolean spacekey)
{
this.leftKey = leftKey;
this.rightKey = rightKey;
this.upkey = upkey;
this.downkey = downkey;
this.spacekey = spacekey;
}
public void move(){
if(this.xpos > 0)this.xpos = (this.leftKey ? this.xpos-8:this.xpos);
if(this.xpos < Comum.LARGURA-(this.getLARGURA())*2)this.xpos = (this.rightKey ? this.xpos+8:this.xpos);
if(this.ypos < 650)this.ypos = (this.downkey ? this.ypos+8:this.ypos);
if(this.ypos > 5)this.ypos = (this.upkey ? this.ypos-8:this.ypos);
}
public int getPlayerExplosion() {
return playerExplosion;
}
public void setPlayerExplosion(int playerExplosion) {
this.playerExplosion = playerExplosion;
}
public static int getLARGURA() {
return LARGURA;
}
public static int getALTURA() {
return ALTURA;
}
public int getScorePt() {
return scorePt;
}
public void setScorePt(int scorePt) {
this.scorePt = scorePt;
}
}
| [
"Davidqpinho@david"
] | Davidqpinho@david |
0b7382f9daf703aa748e5dd9f10f428ea3b4d4ff | 89a7775df216e937c427ca12ceedac5b91779d7f | /src/com/company/Queue/Queue.java | 9c6b378a65b4c2e781e160f004a5995bcea2f445 | [] | no_license | Rasper4o/OracleDemos | e6beb08332f32d2bd030cbc859cab68aeb49b0e4 | c59cadb75b38f5e522fceaa9227e5e530ef6e0a5 | refs/heads/master | 2021-06-23T12:34:56.993790 | 2017-07-29T19:59:41 | 2017-07-29T19:59:41 | 97,162,207 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 592 | java | package com.company.Queue;
/**
* Created by Georgi on 13.7.2017 г..
*/
public class Queue {
char q[];
int putLoc, getLoc;
Queue (int size)
{
q=new char[size];
putLoc=getLoc=0;
}
void put (char ch)
{
if (putLoc==q.length)
{
System.out.println(" -Queue is full.");
return;
}
q[putLoc++]=ch;
}
char get()
{
if (getLoc==putLoc)
{
System.out.println(" -Queue is empty.");
return (char) 0;
}
return q[getLoc++];
}
}
| [
"[email protected]"
] | |
950ae449f4aa29f9b6baab04e65b6d210fb6bbd9 | 0e41158c49736c4bca1ff3afd87e7743803c3bdf | /NJIT/src/com/tree/Tree.java | 864cab9a66e52b275bfcda0fa7707282fe623dd2 | [] | no_license | taunkankur/Innovative | d037ae4272eecaca7ea5d78c550618ca15ade101 | 29e68baeedd0ea9025a18145887064303b7111d1 | refs/heads/master | 2016-09-06T01:17:22.798831 | 2015-07-20T03:14:15 | 2015-07-20T03:14:15 | 27,398,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,191 | java | package com.tree;
public class Tree {
Node root;
public static void main(String[] args) {
Tree tree=new Tree();
tree.addNode(50, "Ankur");
tree.addNode(25, "Ankur");
tree.addNode(15, "Ankur");
tree.addNode(30, "Ankur");
tree.addNode(75, "Ankur");
tree.addNode(85, "Ankur");
tree.addNode(65, "Ankur");
tree.inOrderTraversal(tree.root);
}
public void addNode(int key,String name){
Node newNode=new Node(key,name);
if(root==null){root=newNode;}
else{
Node focusNode=root;
Node parent;
while(true){
parent=focusNode;
if(key<focusNode.key){
focusNode=focusNode.leftNode;
if(focusNode==null){
parent.leftNode=newNode;
return;
}
}else{
focusNode=focusNode.rightNode;
if(focusNode==null){
parent.rightNode=newNode;
return;
}
}
}
}
}
public void inOrderTraversal(Node focusNode){
if(focusNode!=null){
inOrderTraversal(focusNode.leftNode);
inOrderTraversal(focusNode.rightNode);
System.out.println(focusNode.key+" AND "+focusNode.name);
}
}
}
| [
"[email protected]"
] | |
00cf87b7c008335badd439b4309fa1a87e4ecc38 | 8f322f02a54dd5e012f901874a4e34c5a70f5775 | /src/main/java/PTUCharacterCreator/Feats/Cute_Cuddle_Rank_2.java | 6e077a1ba421c1bb0e442dabcb254087e530a83a | [] | no_license | BMorgan460/PTUCharacterCreator | 3514a4040eb264dec69aee90d95614cb83cb53d8 | e55f159587f2cb8d6d7b456e706f910ba5707b14 | refs/heads/main | 2023-05-05T08:26:04.277356 | 2021-05-13T22:11:25 | 2021-05-13T22:11:25 | 348,419,608 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 694 | java | package PTUCharacterCreator.Feats;
import PTUCharacterCreator.Trainer;
import PTUCharacterCreator.Feature;
public class Cute_Cuddle_Rank_2 extends Feature {
{
name = "Cute Cuddle Rank 2";
tags = "[Ranked 2]";
frequency = "X AP - Special";
effect = "Your Pokemon with at least 3d6 in their Cute Stat from Poffins may activate Cute Cuddle as a Standard Action to perform one of the following Moves. They must still follow frequency limits as usual for these Moves. X is the Rank of the chosen Move. Rank 2: Teeter Dance, Attract";
prereqs.put("Charm", 5);
}
public Cute_Cuddle_Rank_2(){}
@Override
public boolean checkPrereqs(Trainer t) {
return t.checkSkillRank("Charm",5);
}
} | [
"[email protected]"
] | |
a0b12e4a42d57839c5144e8dca5aba7e05c9f34a | bef3f708eadf1c99be9582a886c4350b7c029c41 | /Application/src/main/java/es/dlacalle/common/logger/LogWrapper.java | ea5bf4fe29465475591ae55cc0fbc310aac355b5 | [
"Apache-2.0"
] | permissive | kraventh/PFG | 17520068c066af7733ca72985c45a0f79c1a3db0 | 2723808c429ff37bfd4ee580b61011ce3f98064f | refs/heads/master | 2016-09-03T07:15:41.919675 | 2015-03-27T10:58:46 | 2015-03-27T10:58:46 | 32,335,481 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,761 | java | /*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package es.dlacalle.common.logger;
import android.util.Log;
/**
* Helper class which wraps Android's native Log utility in the Logger interface. This way
* normal DDMS output can be one of the many targets receiving and outputting logs simultaneously.
*/
public class LogWrapper implements LogNode {
// For piping: The next node to receive Log data after this one has done its work.
private LogNode mNext;
/**
* Returns the next LogNode in the linked list.
*/
public LogNode getNext() {
return mNext;
}
/**
* Sets the LogNode data will be sent to..
*/
public void setNext(LogNode node) {
mNext = node;
}
/**
* Prints data out to the console using Android's native log mechanism.
* @param priority Log level of the data being logged. Verbose, Error, etc.
* @param tag Tag for for the log data. Can be used to organize log statements.
* @param msg The actual message to be logged. The actual message to be logged.
* @param tr If an exception was thrown, this can be sent along for the logging facilities
* to extract and print useful information.
*/
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
// There actually are log methods that don't take a msg parameter. For now,
// if that's the case, just convert null to the empty string and move on.
String useMsg = msg;
if (useMsg == null) {
useMsg = "";
}
// If an exeption was provided, convert that exception to a usable string and attach
// it to the end of the msg method.
if (tr != null) {
msg += "\n" + Log.getStackTraceString(tr);
}
// This is functionally identical to Log.x(tag, useMsg);
// For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
Log.println(priority, tag, useMsg);
// If this isn't the last node in the chain, move things along.
if (mNext != null) {
mNext.println(priority, tag, msg, tr);
}
}
}
| [
"[email protected]"
] | |
5269d94b4b2803133950973d8a78edbc2d37296d | a33aac97878b2cb15677be26e308cbc46e2862d2 | /data/libgdx/Array_contains.java | ce24bb48bcbb12f312660e02154c8b7e9051cd2b | [] | no_license | GabeOchieng/ggnn.tensorflow | f5d7d0bca52258336fc12c9de6ae38223f28f786 | 7c62c0e8427bea6c8bec2cebf157b6f1ea70a213 | refs/heads/master | 2022-05-30T11:17:42.278048 | 2020-05-02T11:33:31 | 2020-05-02T11:33:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | /**
* Returns if this array contains value.
* @param value May be null.
* @param identity If true, == comparison will be used. If false, .equals() comparison will be used.
* @return true if array contains value, false if it doesn't
*/
public boolean contains(T value, boolean identity) {
T[] items = this.items;
int i = size - 1;
if (identity || value == null) {
while (i >= 0) if (items[i--] == value)
return true;
} else {
while (i >= 0) if (value.equals(items[i--]))
return true;
}
return false;
}
| [
"[email protected]"
] | |
79b67ab48aa579fb45f0268c85455ef02e58ed48 | 8d0d042a54fe6c70d34e434ac721d84a2f9b0906 | /webdriver/Example.java | cea9a1bc76712392b4254280c2be5d7ee77c8e12 | [] | no_license | WhiteboxHub/JuneBatch2018 | 2f00860060e81107650f97996ff2c0bef60e544c | 22b80d2bc5a02dfaa247a78c6f4d87cf98b849f6 | refs/heads/master | 2020-03-25T22:15:35.246223 | 2018-08-15T22:09:33 | 2018-08-15T22:09:33 | 144,213,002 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,280 | java | package com.wbl;
import java.awt.AWTException;
import java.io.IOException;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class Example {
public static WebDriver driver;
public static void main(String args[]) throws AWTException, IOException, InterruptedException{
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"//resources//chromedriver.exe");
driver = new ChromeDriver();
useScrolling();
}
public static void mouseHoverDepartment() {
WebElement dept = driver.findElement(By.id("header-GlobalLefthandNav-toggle-1"));
Actions action = new Actions(driver);
action.moveToElement(dept).perform();//mouse hover build().perform()
dept = driver.findElement(By.id("superDeptId-0"));
//WebDriverWait wait = new WebDriverWait(driver,10);
// dept = wait.until(ExpectedConditions.visibilityOfElementLocated(dept));
action.moveToElement(dept).perform();
}
public static void useScrolling() {
// javascript code to check if the page is completely loaded
driver.get("https://www.walmart.com/");
((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");
System.out.println("Document loaded............");
((JavascriptExecutor)driver).executeScript("window.scrollBy(0, 1200)");
System.out.println("scrolling down...............");
}
public static void learnCookie() {
Set <Cookie> set = driver.manage().getCookies();
System.out.println("set size "+set.size());
for(Cookie e : set)
System.out.println("name="+e.getName() + "#" + e.getExpiry());
Cookie cookie = new Cookie("key","value");
driver.manage().addCookie(cookie);
set = driver.manage().getCookies();
System.out.println("set size after adding "+set.size());
driver.manage().deleteCookieNamed("key");
set = driver.manage().getCookies();
System.out.println("set size after deletion "+set.size());
}
}
| [
"[email protected]"
] | |
0908f222d8d89a856926a2ab01ad1febe3b77c94 | efdfb8d1779e281956ce76c465926f16908dfcd5 | /src/main/java/org/keirobm/jpacriteriabuilder/jpaquerybuilder/onequeryhelpers/ConditionBuilder.java | 5f85d765e7beafbb9f976dbe61c53f1d4d65614d | [] | no_license | tekeiro/experiment-criteria-search | abb922cb29cfe12a1338a2059e1dc3b2182c476a | cb1bf79e22ba9b129b94eb6ac3dee0a780334d80 | refs/heads/master | 2020-03-17T08:10:26.905214 | 2018-05-14T22:19:19 | 2018-05-14T22:19:19 | 133,427,138 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,002 | java | package org.keirobm.jpacriteriabuilder.jpaquerybuilder.onequeryhelpers;
import org.keirobm.jpacriteriabuilder.jpaquerybuilder.CriteriaData;
import org.keirobm.jpacriteriabuilder.jpaquerybuilder.OperationsSupported;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* Build a condition for a Criteria
*
* @author Angel Biedma
*/
public class ConditionBuilder {
private static final DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
private final String letter;
public ConditionBuilder(String letter) {
this.letter = letter;
}
private String parseDbColumna(String dbCol) {
return dbCol.replaceAll("%l", letter);
}
private String parseArg(Object arg) {
if (arg instanceof String)
return "'" + arg.toString() + "'";
else if (arg instanceof Date)
return "'" + df.format((Date) arg) + "'";
return arg.toString();
}
private String parseArgAsStringPart(Object arg) {
if (arg instanceof Date)
return df.format((Date) arg);
return arg.toString();
}
private String parseArgList(List<Object> args) {
return args.stream()
.map(this::parseArg)
.collect(Collectors.joining(","))
;
}
public String buildCondition(CriteriaData critData, List<Object> args) {
Objects.requireNonNull(critData);
Objects.requireNonNull(args);
final OperationsSupported op = critData.getOperation();
switch (op) {
case IS_TRUE:
return String.format("%s = TRUE", parseDbColumna(critData.getDbColumna()));
case IS_FALSE:
return String.format("%s = FALSE", parseDbColumna(critData.getDbColumna()));
case IS_NOTNULL:
return String.format("%s IS NOT NULL", parseDbColumna(critData.getDbColumna()));
case IS_NULL:
return String.format("%s IS NULL", parseDbColumna(critData.getDbColumna()));
case GT:
return String.format("%s > %s",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0))
);
case LT:
return String.format("%s < %s",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0))
);
case GTEQ:
return String.format("%s >= %s",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0))
);
case LTEQ:
return String.format("%s <= %s",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0))
);
case NOTEQ:
return String.format("%s != %s",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0))
);
case EQ:
return String.format("%s > %s",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0))
);
case RANGE:
return String.format("(%s BETWEEN %s AND %s)",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0)),
parseArg(args.get(1))
);
case NOT_IN:
return String.format("%s NOT IN (%s)",
parseDbColumna(critData.getDbColumna()),
parseArgList(args)
);
case IN:
return String.format("%s IN (%s)",
parseDbColumna(critData.getDbColumna()),
parseArgList(args)
);
case STR_STARTS:
return String.format("%s LIKE '%s%%'",
parseDbColumna(critData.getDbColumna()),
parseArgAsStringPart(args.get(0))
);
case STR_ENDS:
return String.format("%s LIKE '%%%s'",
parseDbColumna(critData.getDbColumna()),
parseArgAsStringPart(args.get(0))
);
case STR_CONTAINS:
return String.format("%s LIKE '%%%s%%'",
parseDbColumna(critData.getDbColumna()),
parseArgAsStringPart(args.get(0))
);
case DATES_BETWEEN:
return String.format("(%s BETWEEN %s AND %s)",
parseDbColumna(critData.getDbColumna()),
parseArg(args.get(0)),
parseArg(args.get(1))
);
}
return null;
}
}
| [
"[email protected]"
] | |
ee097ca90989eb9a2ec90ed247b7ff5ad7f8954e | 30642413547d5f37bdd4b22a5db8d9bd82f20b79 | /src/day06nestedifternaryswitchstringmethods/Ternary01.java | 0c426e561aa13e0a41eea2af57bce1c8c9fa4eb5 | [] | no_license | erdemcicek/winterjavaErdem | 0136f5582cb6beb285b50f9553e280b5ff586e7a | 00d8583e5a6147f82129db32bc187196aa8b3f06 | refs/heads/master | 2023-08-11T08:59:15.704623 | 2021-09-22T14:57:18 | 2021-09-22T14:57:18 | 367,855,526 | 0 | 0 | null | null | null | null | WINDOWS-1250 | Java | false | false | 1,180 | java | package day06nestedifternaryswitchstringmethods;
import java.util.Scanner;
public class Ternary01 {
/*
Type java code by using ternary and if-else, ask user to enter an integer, if the integer is even,
the output will be “The integer is even”. If the integer is odd, the output will be “The integer is odd”.
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter an integer...");
int a = scan.nextInt();
// Condition , Question Mark , Code will be executed if cond° is true , Colon , Code will be executed if cond° false
// a % 2 == 0 ? "The integer is even" : "The integer is odd";
String result1 = a % 2 == 0?"even":"odd";
System.out.println(result1);
/*
Type java code by using ternary.
Ask user to enter two integers.
Write a program to print the minimum one on the console.
*/
// Second Question
System.out.println("Enter 2 integers");
int b = scan.nextInt();
int c = scan.nextInt();
int result2 = b > c ? c : b;
System.out.println(result2);
scan.close();
}
}
| [
"erdem25123@gmail"
] | erdem25123@gmail |
2124a91e0482f285cb437b15d94255c96d21ef35 | 946e5633784d3350cf3ac9cbd59f24059e3496b0 | /src/br/com/constran/util/ServerResponse.java | bdec8e8fe63208cb8ada7c13a8ef71a28a644d61 | [] | no_license | molabss/samcentral | 4b151cf0e4dca286c917b1e77faa2b02f337f8bf | ba629f7e71025186833bb781e9fa3f9d43e6d45d | refs/heads/master | 2021-01-10T06:10:04.171721 | 2016-04-18T18:14:37 | 2016-04-18T18:14:37 | 48,434,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,124 | java | package br.com.constran.util;
public class ServerResponse{
public static final String E10 = "E10-INTERNAL_SERVER_ERROR-LOGICA DE PROGRAMACAO";
public static final String E15 = "E15-INTERNAL_SERVER_ERROR-BANCO DE DADOS";
public static final String E20 = "E20-BAD_REQUEST-PARAMETROS INCOMPLETOS";
public static final String E25 = "E25-UNAUTHORIZED-ACAO NAO AUTORIZADA NAS ATUAIS CONDICOES";
public static final String E30 = "E30-INTERNAL_SERVER_ERROR-CRIACAO DE DIRETORIO DE ARQUIVO";
public static final String E35 = "E35-INTERNAL_SERVER_ERROR-CRIACAO DE ARQUIVO";
public static final String E40 = "E40-INTERNAL_SERVER_ERROR-DESSERIALIZACAO DE DADOS JSON";
public static final String E45 = "E45-NOT_FOUND-OS PARAMETROS INFORMADOS NAO SAO VALIDOS PARA PROCESSAR A REQUISICAO.";
private Object entity;
private String serverMessageUser;
private String serverMessageConsole;
private String troubleShootData;
private String codeError;
private Throwable rootCause;
private String redirectTo;
private boolean redirect = false;
public ServerResponse(){
}
public ServerResponse(String serverMessageUser,String redirectTo){
this.redirectTo = redirectTo;
this.serverMessageUser = serverMessageUser;
}
public ServerResponse(String serverMessageUser){
this.serverMessageUser = serverMessageUser;
}
public ServerResponse(Object entity, String serverMessageUser){
this.entity = entity;
this.serverMessageUser = serverMessageUser;
}
public ServerResponse(Object entity,String serverMessageUser,String serverMessageConsole){
this.entity = entity;
this.serverMessageUser = serverMessageUser;
this.serverMessageConsole = serverMessageConsole;
}
/*
public ServerResponse(String serverMessageUser,String serverMessageConsole){
this.serverMessageUser = serverMessageUser;
this.serverMessageConsole = serverMessageConsole;
}
*/
public ServerResponse(String serverMessageUser,String serverMessageConsole,String codeError){
this.serverMessageUser = serverMessageUser;
this.serverMessageConsole = serverMessageConsole;
this.codeError = codeError;
}
public ServerResponse(String serverMessageUser,String serverMessageConsole, Throwable rootCause){
this.serverMessageUser = serverMessageUser;
this.serverMessageConsole = serverMessageConsole;
this.rootCause = rootCause;
}
public ServerResponse(String serverMessageUser,String serverMessageConsole, Throwable rootCause, String codeError){
this.serverMessageUser = serverMessageUser;
this.serverMessageConsole = serverMessageConsole;
this.rootCause = rootCause;
}
public ServerResponse(String serverMessageUser,String serverMessageConsole, String troubleShootData, String codeError){
this.serverMessageUser = serverMessageUser;
this.serverMessageConsole = serverMessageConsole;
this.troubleShootData = troubleShootData;
this.codeError = codeError;
}
public String getServerMessageUser() {
return serverMessageUser;
}
public void setServerMessageUser(String serverMessageUser) {
this.serverMessageUser = serverMessageUser;
}
public String getServerMessageConsole() {
return serverMessageConsole;
}
public void setServerMessageConsole(String serverMessageConsole) {
this.serverMessageConsole = serverMessageConsole;
}
public String getTroubleShootData() {
return troubleShootData;
}
public void setTroubleShootData(String troubleShootData) {
this.troubleShootData = troubleShootData;
}
public Object getEntity() {
return entity;
}
public void setEntity(Object entity) {
this.entity = entity;
}
public String getCodeError() {
return codeError;
}
public void setCodeError(String codeError) {
this.codeError = codeError;
}
public Throwable getRootCause() {
return rootCause;
}
public void setRootCause(Throwable rootCause) {
this.rootCause = rootCause;
}
public String getRedirectTo() {
return redirectTo;
}
public void setRedirectTo(String redirectTo) {
this.redirectTo = redirectTo;
}
public boolean isRedirect() {
return redirect;
}
public void setRedirect(boolean redirect) {
this.redirect = redirect;
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.