blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2
values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 7 5.41M | extension stringclasses 11
values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ce5abab3dd1655f6376e4e7e44b1c74f69d8d90e | c990616756b31366ae467370c2457ddbe9c5a408 | /IdeaProjects/department/src/main/Java/com/offon/department/dao/impl/EmployeeDaoImpl.java | 76c21f71876a59a836ce54bd2f7250dd84e9c692 | [] | no_license | yv-xiang/- | 37bef3d97165be16d096a6378389168c564d56cc | d3bbd63bf71519694db93cb87884c0c964787cf4 | refs/heads/master | 2023-08-08T17:54:07.061860 | 2023-07-24T06:09:25 | 2023-07-24T06:09:25 | 293,981,357 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,056 | java | package com.offon.department.dao.impl;
import com.offon.department.bean.Eept;
import com.offon.department.bean.Employee;
import com.offon.department.dao.EmployeeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.sql.JDBCType;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
@Repository
public class EmployeeDaoImpl implements EmployeeDao {
@Autowired
private JdbcTemplate template;
@Override
public List<Employee> findallEmp() {
String sql =" select t_employee.id,t_employee.name,sex,registerDate,dept_id from t_employee ";
return template.query(sql, new RowMapper<Employee>() {
@Override
public Employee mapRow(ResultSet resultSet, int i) throws SQLException {
Employee employee = new Employee();
employee.setId(resultSet.getInt("id"));
employee.setName(resultSet.getString("name"));
employee.setSex(resultSet.getString("sex"));
employee.setRegisterDate(resultSet.getDate("registerDate"));
return employee;
}
});
}
@Override
public int insertEmp(Employee employee) {
String sql = "inert into t_employee(name,sex,registerDate,dept_id)values(?,?,?,?) ";
return template.update(sql,employee.getName(),employee.getSex(),employee.getRegisterDate(),employee.getDept_id());
}
@Override
public int updateEmp(Employee employee) {
String sql ="update t_employee set name=?,sex=?,registerDate=?,dept_id=? ";
return template.update(sql,employee.getName(),employee.getSex(),employee.getRegisterDate(),employee.getDept_id(),employee.getDept_id());
}
@Override
public int deleteEmpById(Integer id) {
String sql = "delete from t_employee where id=? ";
return template.update(sql,id);
}
}
| [
"2055535458@qq.com"
] | 2055535458@qq.com |
c6dded2f84c5de89916bf374a84f537dd24872c9 | 9f325eae3caee73b309c090fddc331d41cd4d356 | /xydmall-common/src/main/java/com.edu118.common/service.commodity/CategoryBrandRelationService.java | ed98e73f6e6379858277e08c4448f2b9aed9a51e | [] | no_license | EvenNearBoatWater/newxydmall | acc5e75b54da488964a4021eebfb0aae0d0870c5 | 13072c5fa6c4bd15bffe05d8a4ed1f83789cdf8a | refs/heads/master | 2022-12-14T02:17:24.171876 | 2020-09-17T08:56:37 | 2020-09-17T08:56:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 497 | java | package com.edu118.common.service.commodity;
import com.baomidou.mybatisplus.extension.service.IService;
import com.edu118.common.utils.PageUtils;
import com.edu118.common.entity.commodity.CategoryBrandRelationEntity;
import java.util.Map;
/**
* 品牌分类关联
*
* @author muyu
* @email 1235767@qq.com
* @date 2020-09-16 21:58:42
*/
public interface CategoryBrandRelationService extends IService<CategoryBrandRelationEntity> {
PageUtils queryPage(Map<String, Object> params);
}
| [
"1225001172@qq.com"
] | 1225001172@qq.com |
b5de48c7a43b929638d79bee949f2fc3cc6f895d | 86beb40b18fe95f7bac1617842a71e6c5d76b79d | /android/FMLivePlayer/src/com/netease/neliveplayerdemo/services/NELivePlayerService.java | de7c155fd6fcf16b9fb64fce2cfb297aec7a38ba | [] | no_license | 84489556/hxg_app115_rn_upgrade | 094130894ccc2ce28a67f50e05c7c25a6b377512 | 700981f94097c09469845d405d1e66d46443668a | refs/heads/master | 2022-12-11T10:19:18.926962 | 2020-09-09T07:45:36 | 2020-09-09T07:45:36 | 294,039,826 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,262 | java | package com.netease.neliveplayerdemo.services;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import androidx.annotation.Nullable;
import com.netease.neliveplayer.NELivePlayer;
/**
* Created by netease on 17/4/6.
*/
public class NELivePlayerService extends Service{
private static NELivePlayer sMediaPlayer;
public static Intent newIntent(Context context) {
Intent intent = new Intent(context, NELivePlayerService.class);
return intent;
}
public static void intentToStart(Context context) {
context.startService(newIntent(context));
}
public static void intentToStop(Context context) {
context.stopService(newIntent(context));
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
public static void setMediaPlayer(NELivePlayer mp) {
if (sMediaPlayer != null && sMediaPlayer != mp) {
if (sMediaPlayer.isPlaying())
sMediaPlayer.stop();
sMediaPlayer.release();
sMediaPlayer = null;
}
sMediaPlayer = mp;
}
public static NELivePlayer getMediaPlayer() {
return sMediaPlayer;
}
}
| [
"ydwgl@ydwgl.local"
] | ydwgl@ydwgl.local |
b1077dbeae641d95d6d5651cddfa157170e70fa0 | 8565df5db896e6a608c1f1c584a3467a34a98e18 | /src/main/java/com/exadel/project/trainee/service/ConfirmTraineeEmailService.java | 0e08153e88885c7bf7b67d6a57f903b525dbb98e | [] | no_license | serkushner/backend-team1 | bf8c210df7a1451f38c9eadfff3fbe825556ae18 | 0b2403e9698a4467f83d2f93f10ec7adaf57b577 | refs/heads/master | 2023-04-21T18:38:15.179953 | 2021-05-23T09:09:27 | 2021-05-23T09:09:27 | 350,991,314 | 1 | 1 | null | 2021-05-23T09:09:28 | 2021-03-24T07:50:19 | Java | UTF-8 | Java | false | false | 1,442 | java | package com.exadel.project.trainee.service;
import com.exadel.project.common.exception.EntityNotFoundException;
import com.exadel.project.common.exception.TokenIsNotValidException;
import com.exadel.project.common.exception.TraineeAlreadyConfirmEmailException;
import com.exadel.project.configurations.JwtConfiguration;
import com.exadel.project.trainee.entity.AdditionalInfo;
import com.exadel.project.trainee.entity.TraineeStatus;
import com.exadel.project.trainee.repository.AdditionalInfoRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class ConfirmTraineeEmailService {
private final JwtConfiguration jwtConfiguration;
private final AdditionalInfoRepository additionalInfoRepository;
public void confirmTraineeEmail(String token) {
if (jwtConfiguration.validateToken(token)) {
AdditionalInfo additionalInfo = additionalInfoRepository.findById(Long.parseLong(jwtConfiguration.getIdFromToken(token))).orElseThrow(EntityNotFoundException::new);
if (additionalInfo.getTraineeStatus() == TraineeStatus.EMAIL_NOT_CONFIRM) {
additionalInfo.setTraineeStatus(TraineeStatus.REGISTERED);
additionalInfoRepository.save(additionalInfo);
} else throw new TraineeAlreadyConfirmEmailException();
} else
throw new TokenIsNotValidException();
}
}
| [
"noreply@github.com"
] | noreply@github.com |
13c23935d9e95db551faaeff09a90fef50b9a2f5 | b9b6c15155a17703d7add9b9badcbeb5f9f61aae | /COBieBIMServerShared/src/org/erdc/cobie/shared/bimserver/cobietab/deserialization/propertysets/Pset_Specification.java | 35166e040834bbb8d11f179caf5cabcc4952992f | [] | no_license | webdada/COBie-plugins | abf0a091d7a6ac59a7af86cbbd1d75f974049b82 | 4dc4b75f9026f47887258eeb67117188e3654668 | refs/heads/master | 2020-12-29T00:29:18.828171 | 2015-04-23T08:43:18 | 2015-04-23T08:43:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,356 | java | package org.erdc.cobie.shared.bimserver.cobietab.deserialization.propertysets;
/******************************************************************************
* Copyright (C) 2011 ERDC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Factory;
import org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue;
import org.bimserver.models.ifc2x3tc1.impl.IfcPropertySetImpl;
import org.erdc.cobie.sheetxmldata.TypeType;
public class Pset_Specification extends IfcPropertySetImpl
{
public static enum SpecificationTypeField
{
NominalLength, NominalWidth, NominalHeight, ModelReference, Shape, Size, Color, Finish, Grade, Material, Constituents, Features, AccessibilityPerformance, CodePerformance, SustainabilityPerformance
}
public static final String pSetName = "COBie_Pset_Specification";
public static final String pSetDescriptionPrefix = "Properties for ";
public static final String propertyDescriptionPrefix = "Value for ";
public Pset_Specification()
{
super();
setDirectAttributes();
initializeSingleValueAttributes();
}
public Pset_Specification(TypeType type)
{
this();
setDescription(pSetDescriptionPrefix + type.getExtObject());
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.NominalLength.toString(), this,
PropertyUtility.initializeLabel(type.getNominalLength()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.NominalWidth.toString(), this,
PropertyUtility.initializeLabel(type.getNominalWidth()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.NominalHeight.toString(), this,
PropertyUtility.initializeLabel(type.getNominalHeight()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.ModelReference.toString(), this,
PropertyUtility.initializeLabel(type.getModelReference()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Shape.toString(), this,
PropertyUtility.initializeLabel(type.getShape()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Size.toString(), this,
PropertyUtility.initializeLabel(type.getSize()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Color.toString(), this,
PropertyUtility.initializeLabel(type.getColor()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Finish.toString(), this,
PropertyUtility.initializeLabel(type.getFinish()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Grade.toString(), this,
PropertyUtility.initializeLabel(type.getGrade()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Material.toString(), this,
PropertyUtility.initializeLabel(type.getMaterial()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Constituents.toString(), this,
PropertyUtility.initializeLabel(type.getConstituents()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.Features.toString(), this,
PropertyUtility.initializeLabel(type.getFeatures()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.AccessibilityPerformance.toString(), this,
PropertyUtility.initializeLabel(type.getAccessibilityPerformance()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.CodePerformance.toString(), this,
PropertyUtility.initializeLabel(type.getCodePerformance()));
PropertySetUtility.setPropertySetPropertyValueOfName(SpecificationTypeField.SustainabilityPerformance.toString(), this,
PropertyUtility.initializeLabel(type.getSustainabilityPerformance()));
}
public void initializeSingleValueAttributes()
{
for (SpecificationTypeField field : SpecificationTypeField.values())
{
IfcPropertySingleValue sVal = Ifc2x3tc1Factory.eINSTANCE.createIfcPropertySingleValue();
sVal.setName(field.toString());
sVal.setDescription(propertyDescriptionPrefix + sVal.getName());
getHasProperties().add(sVal);
}
}
public void setDirectAttributes()
{
setName(pSetName);
setDescription(pSetDescriptionPrefix);
}
}
| [
"chrisbogen@gmail.com"
] | chrisbogen@gmail.com |
65ac26a5a544e11be898182700b907afa839717c | a80da057b366c22e5fe9091bb284ec0865836c97 | /mvpfw/src/main/java/com/yu/retrofittest/base/IPresenter.java | 528a771f056a9d16b94303e4eee4c9b4c0a48f09 | [] | no_license | yuli2039/Common | 8c119a6632aa1dca2b2ecdd65280412f11642763 | 88057142664a6d3827571cd46bd75755ea5df75c | refs/heads/master | 2020-05-21T16:45:11.876895 | 2017-02-20T05:59:41 | 2017-02-20T05:59:41 | 63,852,894 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 249 | java | package com.yu.retrofittest.base;
/**
* @author yu
* Create on 2016/12/5.
*/
public interface IPresenter {
void onCreate();
void onStart();
void onResume();
void onPause();
void onStop();
void onDestory();
}
| [
"229868243@qq.com"
] | 229868243@qq.com |
90dc887a23afe052c87d9a50767b85e1037dad7f | 425ac2b3d2ba036202c1dc72c561d3a904df33ad | /support/cas-server-support-webauthn/src/main/java/org/apereo/cas/config/ConditionalOnWebAuthnEnabled.java | ecf778ff182131b2bd82075cdf93591dd76edbbc | [
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | fogbeam/cas_mirror | fee69b4b1a7bf5cac87da75b209edc3cc3c1d5d6 | b7daea814f1238e95a6674663b2553555a5b2eed | refs/heads/master | 2023-01-07T08:34:26.200966 | 2021-08-12T19:14:41 | 2021-08-12T19:14:41 | 41,710,765 | 1 | 2 | Apache-2.0 | 2022-12-27T15:39:03 | 2015-09-01T01:53:24 | Java | UTF-8 | Java | false | false | 690 | java | package org.apereo.cas.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This is {@link ConditionalOnWebAuthnEnabled}.
*
* @author Misagh Moayyed
* @since 6.4.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@ConditionalOnProperty(prefix = "cas.authn.mfa.web-authn.core", name = "enabled", havingValue = "true", matchIfMissing = true)
public @interface ConditionalOnWebAuthnEnabled {
}
| [
"cas@apereo.org"
] | cas@apereo.org |
e49bd6cea741a659c438f034f324d3d8ebbc0064 | a969cad6bd19313831e9d6a7c1d42bc1f5c7274d | /java-design-pattern/src/main/java/com/coffee/baby/pattern/dynamicproxy/DynamicProxyTest.java | 67e842b9eaf0482f9ef44463f5d2839c11e9124b | [
"Apache-2.0"
] | permissive | smileszx/coffeebaby | e763f9f53b28f02b2a88db2a739d8d208d2a6ab6 | ad97d4ef8ef646754bbb2cac8c4a1b863f43f892 | refs/heads/master | 2022-12-21T08:36:24.180180 | 2019-07-03T15:13:38 | 2019-07-03T15:13:38 | 166,063,592 | 0 | 0 | Apache-2.0 | 2022-12-16T04:49:05 | 2019-01-16T15:30:45 | Java | UTF-8 | Java | false | false | 532 | java | package com.coffee.baby.pattern.dynamicproxy;
import java.lang.reflect.Proxy;
/**
* @Description TODO
* @Author Thinkpad
* @Date 2019/1/28 14:50
**/
public class DynamicProxyTest {
public static void main(String[] args) {
TargetObjectImpl object = new TargetObjectImpl();
TagetObject proxy = (TagetObject) Proxy.newProxyInstance(JdkDynamicProxy.class.getClassLoader(), new Class[] {TagetObject.class}, new JdkDynamicProxy(object));
proxy.doSomethig();
proxy.doSomethingElse();
}
}
| [
"smile.szx@outlook.com"
] | smile.szx@outlook.com |
5dda337330165d531c3e33e1fb1f8b080af48440 | fd751521940dca993d92d5fb95a374dbf58eb7bf | /final-framework-testng/src/com/training/pom/UNF_090_Products_POM.java | c1ae84d78f5f09096b8cf369d53a2d6989e5eec3 | [] | no_license | sreedevisree/NewProject | 7b79ba5fc1dab6339fce412209a2b2082fb8e255 | cc53bd10ed44d69f46b66a5cee569c62bbf8afb1 | refs/heads/master | 2020-04-22T08:56:16.381382 | 2019-03-11T08:29:59 | 2019-03-11T08:29:59 | 170,254,889 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,325 | java | package com.training.pom;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class UNF_090_Products_POM {
private WebDriver driver;
public UNF_090_Products_POM(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
//adding product details of the catalog icon
@FindBy(xpath="//div[@class='pull-right']//a[@class='btn btn-primary']")
private WebElement addProd_CatalogIcn;
public void clickAddProd_CatalogIcn(){
this.addProd_CatalogIcn.click();
}
//clicking on save button
@FindBy(xpath="//button[@type='submit']")
private WebElement saveBtn_CatalogIcn;
public void clickSaveBtn_CatalogIcn(){
this.saveBtn_CatalogIcn.click();
}
//get the confirmation message
@FindBy(xpath="//*[@id='content']/div[2]/div[1]")
private WebElement confirProdMsg__CatalogIcn;
public String getConfirProdMsg__CatalogIcn(){
return this.confirProdMsg__CatalogIcn.getText();
}
//*************Start of Genral Tab
@FindBy(id="input-name1")
private WebElement prodName_GenralTab_ProductLnk_CatalogIcn;
public void setProdName_GenralTab_ProductLnk_CatalogIcn(String prodName){
this.prodName_GenralTab_ProductLnk_CatalogIcn.sendKeys(prodName);
}
//clicking on Meta Tag Title
@FindBy(id="input-meta-title1")
private WebElement metaTitle_GenralTab_ProductLnk_CatalogIcn;
public void setMetaTitle_GenralTab_ProductLnk_CatalogIcn(String metaTitle){
this.metaTitle_GenralTab_ProductLnk_CatalogIcn.sendKeys(metaTitle);
}
//*************End of Genral Tab
//*************start of Data Tab
//click on Data tab
@FindBy(xpath="//a[contains(text(),'Data')]")
private WebElement dataTab_DataTab_ProductLnk_CatalogIcn;
public void clickDataTab_GenralTab_ProductLnk_CatalogIcn(){
this.dataTab_DataTab_ProductLnk_CatalogIcn.click();
}
//setting the model textbox
@FindBy(id="input-model")
private WebElement modelNo_DataTab_ProductLnk_CatalogIcn;
public void setModelNo_DataTab_ProductLnk_CatalogIcn(String modelNo){
this.modelNo_DataTab_ProductLnk_CatalogIcn.clear();
this.modelNo_DataTab_ProductLnk_CatalogIcn.sendKeys(modelNo);
}
//setting the price
@FindBy(id="input-price")
private WebElement price_DataTab_ProductLnk_CatalogIcn;
public void setPrice__DataTab_ProductLnk_CatalogIcn(String price){
this.price_DataTab_ProductLnk_CatalogIcn.clear();
this.price_DataTab_ProductLnk_CatalogIcn.sendKeys(price);
}
//setting the quantity
@FindBy(id="input-quantity")
private WebElement quantity_DataTab_ProductLnk_CatalogIcn;
public void setQuantity_DataTab_ProductLnk_CatalogIcn(String quantity){
this.quantity_DataTab_ProductLnk_CatalogIcn.clear();
this.quantity_DataTab_ProductLnk_CatalogIcn.sendKeys(quantity);
}
//*************End of Data Tab
//*************Start of Links Tab
//clicking on links tab
@FindBy(xpath="//a[contains(text(),'Links')]")
private WebElement linkTab_ProductLnk_CatalogIcn;
public void clickLinkTab_ProductLnk_CatalogIcn(){
this.linkTab_ProductLnk_CatalogIcn.click();
}
//selecting the value from catagory dropdown
@FindBy(id="input-category")
private WebElement category_LinkTab_ProductLnk_CatalogIcn;
public void setCategory_LinkTab_ProductLnk_CatalogIcn(String category){
this.category_LinkTab_ProductLnk_CatalogIcn.click();
////a[contains(text(),'Blazers Test(5-7)')]
driver.findElement(By.xpath("//a[contains(text(),'"+category+"')]")).click();
Actions action = new Actions(driver);
action.sendKeys(Keys.ESCAPE);
/*Select categorySel=new Select(this.category_LinkTab_ProductLnk_CatalogIcn);
categorySel.selectByVisibleText(category);*/
}
//*************End of Links Tab
//*************Start of Discount Tab
//click on discount
@FindBy(xpath="//a[contains(text(),'Discount')]")
private WebElement discountTab_ProductLnk_CatalogIcn;
public void clickDiscountTab_ProductLnk_CatalogIcn(){
this.discountTab_ProductLnk_CatalogIcn.click();
}
@FindBy(xpath="//table[@id='discount']//button[@type='button']")
private WebElement addDiscount_DiscountTab_ProductLnk_CatalogIcn;
public void clickAddDiscount_DiscountTab_ProductLnk_CatalogIcn(){
this.addDiscount_DiscountTab_ProductLnk_CatalogIcn.click();
}
@FindBy(xpath="//td[@class='text-right']//input[@placeholder='Quantity']")
private WebElement quantity_DiscountTab_ProductLnk_CatalogIcn;
public void setQuantity_DiscountTab_ProductLnk_CatalogIcn(String quantity){
this.quantity_DiscountTab_ProductLnk_CatalogIcn.clear();
this.quantity_DiscountTab_ProductLnk_CatalogIcn.sendKeys(quantity);
}
@FindBy(xpath="//td[@class='text-right']//input[@placeholder='Price']")
private WebElement price_DiscountTab_ProductLnk_CatalogIcn;
public void setPrice_DiscountTab_ProductLnk_CatalogIcn(String price){
this.price_DiscountTab_ProductLnk_CatalogIcn.clear();
this.price_DiscountTab_ProductLnk_CatalogIcn.sendKeys(price);
}
@FindBy(xpath = "//input[@placeholder='Date Start']")
private WebElement dateStart_DiscountTab_ProductLnk_CatalogIcn;
// clicking on the start date and getting the current date
public void setDateStart_DiscountTab_ProductLnk_CatalogIcn() {
this.dateStart_DiscountTab_ProductLnk_CatalogIcn.clear();
SimpleDateFormat formattedDate = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
String today1 = (String) (formattedDate.format(c.getTime()));
this.dateStart_DiscountTab_ProductLnk_CatalogIcn.sendKeys(today1);
}
// select the end date from the date picker as current date pulse 1
@FindBy(xpath = "//input[@placeholder='Date End']")
private WebElement dateEnd_DiscountTab_ProductLnk_CatalogIcn;
// clicking on the start date and getting the current date
public void setDateEnd_DiscountTab_ProductLnk_CatalogIcn() {
this.dateEnd_DiscountTab_ProductLnk_CatalogIcn.clear();
SimpleDateFormat formattedDate = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);
String tomorrow = (String) (formattedDate.format(c.getTime()));
System.out.println("tomorrows date is "+tomorrow);
this.dateEnd_DiscountTab_ProductLnk_CatalogIcn.sendKeys(tomorrow);
}
//*************End of Discount Tab
//*************Start of Rewards Point Tab
//clicking on rewards point tab
@FindBy(xpath="//a[@href='#tab-reward']")
private WebElement rewardPtTab_ProductLnk_CatalogIcn;
public void clickRewardPtTab_ProductLnk_CatalogIcn(){
this.rewardPtTab_ProductLnk_CatalogIcn.click();
}
//setting the points
@FindBy(id="input-points")
private WebElement points_RewardsPtTab_ProductLnk_CatalogIcn;
public void setPoints_RewardsPtTab_ProductLnk_CatalogIcn(String points){
this.points_RewardsPtTab_ProductLnk_CatalogIcn.clear();
this.points_RewardsPtTab_ProductLnk_CatalogIcn.sendKeys(points);
}
//*************End of Rewards Point Tab
}
; | [
"sreedevs@in.ibm.com"
] | sreedevs@in.ibm.com |
10a7db0f465d0bd66108be5a66c5cc0d305020f4 | bde0ded5ff9eb1a93fe22e284aa80df6ed5d847c | /core/src/test/java/com/matsg/battlegrounds/item/modifier/FireModeAttributeModifierTest.java | d60fe6927c2dd7538ee4f135c325aafc1aa8a625 | [] | no_license | matsgemmeke/battlegrounds-plugin | ee379db349f6624011fc327daa113414370569ab | 2fbdb6ac6364a804bae16c4698b3338854e0297e | refs/heads/master | 2021-07-17T08:40:43.359600 | 2021-07-14T23:16:04 | 2021-07-14T23:16:04 | 114,624,863 | 5 | 6 | null | 2019-11-11T08:41:53 | 2017-12-18T10:00:31 | Java | UTF-8 | Java | false | false | 3,323 | java | package com.matsg.battlegrounds.item.modifier;
import com.matsg.battlegrounds.api.util.ValueObject;
import com.matsg.battlegrounds.item.factory.FireModeFactory;
import com.matsg.battlegrounds.item.mechanism.FireMode;
import com.matsg.battlegrounds.item.mechanism.SemiAutomatic;
import com.matsg.battlegrounds.util.data.FireModeValueObject;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class FireModeAttributeModifierTest {
private FireModeFactory fireModeFactory;
@Before
public void setUp() {
this.fireModeFactory = new FireModeFactory(null);
}
@Test
public void modifyValidRegexWithoutArgs() {
String regex = "=SEMI_AUTOMATIC";
ValueObject<FireMode> valueObject = new FireModeValueObject(null);
FireModeAttributeModifier modifier = new FireModeAttributeModifier(regex, fireModeFactory);
ValueObject<FireMode> attribute = modifier.modify(valueObject, new String[0]);
assertTrue(attribute instanceof FireModeValueObject);
assertTrue(attribute.getValue() instanceof SemiAutomatic);
}
@Test
public void modifyValidRegexWithArgs() {
String regex = "=arg1";
String[] args = new String[] { "SEMI_AUTOMATIC(1,0)" };
ValueObject<FireMode> valueObject = new FireModeValueObject(null);
FireModeAttributeModifier modifier = new FireModeAttributeModifier(regex, fireModeFactory);
ValueObject<FireMode> attribute = modifier.modify(valueObject, args);
assertTrue(attribute instanceof FireModeValueObject);
assertTrue(attribute.getValue() instanceof SemiAutomatic);
}
@Test(expected = AttributeModificationException.class)
public void modifyInvalidRegexWithoutArgs() {
String regex = "=INVALID";
ValueObject<FireMode> valueObject = new FireModeValueObject(null);
FireModeAttributeModifier modifier = new FireModeAttributeModifier(regex, fireModeFactory);
modifier.modify(valueObject, new String[0]);
}
@Test(expected = AttributeModificationException.class)
public void modifyInvalidFireModeType() {
String regex = "=arg1";
String[] args = new String[] { "INVALID(1,0)" };
ValueObject<FireMode> valueObject = new FireModeValueObject(null);
FireModeAttributeModifier modifier = new FireModeAttributeModifier(regex, fireModeFactory);
modifier.modify(valueObject, args);
}
@Test(expected = AttributeModificationException.class)
public void modifyInvalidRateOfFire() {
String regex = "=arg1";
String[] args = new String[] { "SEMI_AUTOMATIC(INVALID,0)" };
ValueObject<FireMode> valueObject = new FireModeValueObject(null);
FireModeAttributeModifier modifier = new FireModeAttributeModifier(regex, fireModeFactory);
modifier.modify(valueObject, args);
}
@Test(expected = AttributeModificationException.class)
public void modifyInvalidBurst() {
String regex = "=arg1";
String[] args = new String[] { "SEMI_AUTOMATIC(1,INVALID)" };
ValueObject<FireMode> valueObject = new FireModeValueObject(null);
FireModeAttributeModifier modifier = new FireModeAttributeModifier(regex, fireModeFactory);
modifier.modify(valueObject, args);
}
}
| [
"matsgemmeke@gmail.com"
] | matsgemmeke@gmail.com |
7fa9b1c691c1ae17f8e0facdab7c779ae18bd764 | 6198ebcf4b29c289074fe260bfa9bab614172b96 | /src/ShreyaD/AssignQ14_sc.java | b2301d80d9f70d5a6bb8ff629c90393177b132b9 | [] | no_license | KrishnaKTechnocredits/Aug19JavaG1 | affe0db20e2b014650683f9c80ff1062c6276cd9 | a26407fa7f2a443e529c2f6a35e14d0a41df783b | refs/heads/master | 2022-03-09T13:28:42.052516 | 2019-10-01T09:12:45 | 2019-10-01T09:12:45 | 204,036,671 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 580 | java | package ShreyaD;
import java.util.Scanner;
public class AssignQ14_sc {
void Even(int a[]){
for(int i=0;i<a.length;i++)
{
if(a[i]%2==0)
System.out.println("even no is :"+a[i]+" ");
}
}
public static void main(String []args)
{
AssignQ14_sc Q14 = new AssignQ14_sc();
Scanner sc = new Scanner(System.in);
System.out.println("please enter the no");
int size = sc.nextInt();
int num[] = new int[size];
for (int i = 0; i < num.length; i++) {
System.out.println("enter the number of 1st array:");
num[i] = sc.nextInt();
}
Q14.Even(num);
sc.close();
}
}
| [
"shreyadubey1897@gmail.com"
] | shreyadubey1897@gmail.com |
ca1b1ffd6cb5401ba058e36ad48a27f4297b1ff2 | 3226d283d6ef6be4dd98c18b010f19789e315115 | /src/UTILS/Constants.java | 82fec265c7dc6b9bbc2cc3157447784f9420673d | [] | no_license | alklein/Kmeans | feebfcd4f05e4522ba534903ed9237a8d5fe9574 | b419cac9aae274741e5d46b142951a6a0be8af1a | refs/heads/master | 2020-04-01T18:47:23.276488 | 2013-12-10T03:03:15 | 2013-12-10T03:03:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 86 | java | package UTILS;
public class Constants {
public enum METRIC { EUCLIDEAN, DNA};
} | [
"alklein@alumni.stanford.edu"
] | alklein@alumni.stanford.edu |
1d9b3bf9a93e9a9c30118f7408552437b1f85ced | b0cb1c81f766ecf971d7dd97564756dc985ab815 | /soap-sample/src/main/java/net/webservicex/GeoIPServiceHttpGet.java | 9201aa19e99393ea8c82204134a693ddd8ec27d3 | [
"Apache-2.0"
] | permissive | vlucenco/java_learn | edeb42d0ad8ba10ccfc028106d9cfaee76df714d | ee062ee81793c9b4cdc41dfbfc066eabb0ab81fd | refs/heads/master | 2020-04-12T07:20:45.966783 | 2016-09-21T05:54:26 | 2016-09-21T05:54:26 | 63,472,897 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,267 | java | package net.webservicex;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by Apache CXF 3.1.7
* 2016-09-12T07:39:07.667+03:00
* Generated source version: 3.1.7
*
*/
@WebService(targetNamespace = "http://www.webservicex.net/", name = "GeoIPServiceHttpGet")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface GeoIPServiceHttpGet {
/**
* GeoIPService - GetGeoIP enables you to easily look up countries by IP addresses
*/
@WebMethod(operationName = "GetGeoIP")
@WebResult(name = "GeoIP", targetNamespace = "http://www.webservicex.net/", partName = "Body")
public GeoIP getGeoIP(
@WebParam(partName = "IPAddress", name = "IPAddress", targetNamespace = "")
java.lang.String ipAddress
);
/**
* GeoIPService - GetGeoIPContext enables you to easily look up countries by Context
*/
@WebMethod(operationName = "GetGeoIPContext")
@WebResult(name = "GeoIP", targetNamespace = "http://www.webservicex.net/", partName = "Body")
public GeoIP getGeoIPContext();
}
| [
"lucenco.v@gmail.com"
] | lucenco.v@gmail.com |
ffb668130d181075ede6f8ebd62144a9565f94eb | cc0bed7b712f5f4016929df8e065dd1b881ac48e | /app/src/test/java/com/example/iryna/notification/ExampleUnitTest.java | 611b67f8110f17d48933ad3bc1f528426388edea | [] | no_license | Luckygirlllll/Notification | ba7ed720c0012a07358114caae13565e3a319c55 | 64b6f73f7c081ffae2ac61e33cfa1651fe2d90ee | refs/heads/master | 2021-01-10T16:56:53.812510 | 2016-03-05T08:10:05 | 2016-03-05T08:10:05 | 52,957,589 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 323 | java | package com.example.iryna.notification;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"irynakanivets@gmail.com"
] | irynakanivets@gmail.com |
34fee2b02b8726e7ff92c930ad33d1b75557d27d | 28309dce89ac90569d925c119b2ab95a2a7f5634 | /GroceryGoServer/src/Walmart.java | dd5dd94cb3c789a7f018b1c9fbe90d7b7dc42473 | [] | no_license | ChenWangCarleton/234Broject | 947deba103c341f1e6380dfdf4c4cc372db68d2d | 8785563a64f45d03fc5c6792426580a6a2ba535c | refs/heads/master | 2021-09-06T13:15:41.373397 | 2018-02-07T00:06:30 | 2018-02-07T00:06:30 | 102,979,688 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 15,122 | java | import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
public class Walmart{
File target;
PrintWriter fw;
String[] categories= {"Fruits & Vegetables","Deli & Ready Meals","Bakery","Meat & Seafood","Dairy and Eggs","Drinks","Frozen","Pantry"};
String[] links= {"/fruits-and-vegetables/N-3799","/deli/N-3792","/bakery/N-3796","/meat-seafood/N-3793","/dairy-eggs/N-3798","/drinks/N-3791","/frozen-food/N-3795","/pantry-food/N-3794"};
String[] linksBrand= {"/bakery/bagels-buns-rolls/N-3954","/bakery/desserts/N-3846","/bakery/sliced-bread/N-3845","/bakery/wraps-pita-flatbread/N-3955","/dairy-eggs/eggs/N-3850","/dairy-eggs/milk-cream/N-3851","/dairy-eggs/cheese/N-3849","/dairy-eggs/yogurt/N-3853","/deli/hummus-spreads/N-3953","/deli/deli-cheese/N-3817","/deli/deli-meat/N-3818","/grocery/produce/tofu-soy-products/N-4523","/drinks/coffee/N-3815","/drinks/tea-hot-drinks/N-3812","/drinks/water/N-3813","/drinks/juice/N-3810","/frozen-food/ice-cream-treats/N-3828","/frozen-food/meals-sides/N-3826","/frozen-food/pizza/N-3832","/frozen-food/vegetables/N-3825","/fruits/N-3852","/vegetables/N-3854","/salad-greens-herbs/N-4524","/meat-seafood/seafood/N-3824","/meat-seafood/beef/N-3820","/meat-seafood/pork/N-3822","/meat-seafood/poultry/N-3821","/pantry-food/pasta-rice-beans/N-3835","/pantry-food/baking-needs/N-3833","/pantry-food/canned-food/N-3839","/pantry-food/chips-snacks/N-3842","/natural-organic-food/N-3992"};
String noImg="https://assets.shop.loblaws.ca/products/NoImage/b1/en/front/NoImage_front_a06.png";
String url="https://www.walmart.ca/en/grocery";
WebDriver ABdriver;
WebDriver tempDri;
WebDriver dri;
WebDriver driver;
static boolean status=false;
ArrayList<String> brands=new ArrayList<>();//////
ArrayList<String> failUrl=new ArrayList<>();
//method used to convert Germany characters to English.
private static String[][] UMLAUT_REPLACEMENTS = { { new String("Ä"), "A" }, { new String("Ü"), "U" }, { new String("Ö"), "O" }, { new String("ä"), "a" }, { new String("ü"), "u" }, { new String("ö"), "o" }, { new String("ß"), "ss" },{new String("é"),"e"} ,{new String("É"),"E"}};
public static String replaceUmlaute(String orig) {
String result = orig;
for (int i = 0; i < UMLAUT_REPLACEMENTS.length; i++) {
result = result.replace(UMLAUT_REPLACEMENTS[i][0], UMLAUT_REPLACEMENTS[i][1]);
}
return result;
}
//in walmart to avoid go to each item's web page to collect data, we first get the all the brands and then check if an item belongs to one brand.
// this func is used to check if there are hiding brands in each web page
public boolean hasMoreBrand(WebElement w) {
try {
WebElement m=w.findElement(By.className("moreLess"));
// System.out.println("text: "+m.getText()+" link:"+m.getAttribute("link"));
if(m.getAttribute("link").contains("showMoreIds")) {
// m.click();
return true;
}
else return false;
}catch(Exception e) {
e.printStackTrace();
return false;
}
}
//this func is used to collect all the brands in one web page
public String getBrand(ArrayList<String> brands,String name) {// set brand as an attribute. read and store all the brand first.!!!
for(int x=0;x<brands.size();x++) {
if(name.contains(brands.get(x))||name.contains(brands.get(x).toLowerCase())||name.contains(brands.get(x).toUpperCase())) {//startsWith or Contains
return brands.get(x);
}
}
return null;
}
//this func is used to separate brand from item's displaying name. (just to check if the name contains brand from the brands that are already collected
public String removeBrand(String name, String brand) {
if(name.contains(brand)) {
name=name.replace(brand, "");
}
else if(name.contains(brand.toLowerCase())){
name=name.replace(brand.toLowerCase(), "");
}
else if(name.contains(brand.toUpperCase())) {
name=name.replace(brand.toUpperCase(), "");
}
if(name.startsWith(" ")) {
name=name.substring(1);
}
while(name.charAt(name.length()-1)==' '||name.charAt(name.length()-1)==','||name.charAt(name.length()-1)=='.') {
name=name.substring(0, name.length()-1);
}
return name;
}
//this func is used to add brands to brand list. need to filter the special cases
public void addToBrands(String brand) {
HashSet<String> notBrand=new HashSet<>();//considered brand in walmart but not in loblaws and independent
notBrand.add("Coca-Cola");
notBrand.add("Pepsi");
notBrand.add("Dr. Pepper");
notBrand.add("Sprite");
brand=replaceUmlaute(brand);
if(brand.equals("p"))brand="Dare";
if(notBrand.contains(brand))
return;
for(int x=0;x<brands.size();x++) {
if(brands.get(x).equals(brand))
return;
}
brands.add(brand);
}
//func used to run before actually collecting items' data. goes through each major subcategories and collects all the brand
public void addBrand() {
DesiredCapabilities caps=new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:/phantomjs-2.1.1-windows/bin/phantomjs.exe");
for(int ca=0;ca<linksBrand.length;ca++){
ABdriver=new PhantomJSDriver(caps);
String parentUrl=url+linksBrand[ca];
ABdriver.get(parentUrl);
checkPageIsReady(ABdriver);
System.out.println(parentUrl);
WebElement rmBrand=ABdriver.findElement(By.id("rm-Brand"));
if(hasMoreBrand(rmBrand)) {
WebElement a=rmBrand.findElement(By.className("moreLess"));
tempDri=new PhantomJSDriver(caps);
tempDri.get(url+a.getAttribute("link"));
a=tempDri.findElement(By.id("rm-Brand"));
List<WebElement> lis=a.findElements(By.tagName("li"));
for(int x=0;x<lis.size()-1;x++) {
String brand="";
brand=lis.get(x).findElement(By.tagName("input")).getAttribute("name");
if(brand.contains("n/a")||brand.contains("N/A")) {
}
else {
brand=removeMarkSymbol(brand);
addToBrands(brand);
}
}
tempDri.quit();
}
else {
WebElement a=ABdriver.findElement(By.id("rm-Brand"));
List<WebElement> lis=a.findElements(By.tagName("li"));
for(int x=0;x<lis.size()-1;x++) {
String brand="";
brand=lis.get(x).findElement(By.tagName("input")).getAttribute("name");
if(brand.contains("n/a")||brand.contains("N/A")) {
}
else {
brand=removeMarkSymbol(brand);
addToBrands(brand);
}
}
}
ABdriver.quit();
}
}
//function used to start webscraping
public void execute(String targetFile) throws Exception{
status=false;
addBrand();
target=new File(targetFile);
fw=new PrintWriter(new FileWriter(target));
DesiredCapabilities caps=new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:/phantomjs-2.1.1-windows/bin/phantomjs.exe");
for(int ca=0;ca<categories.length;ca++){
driver=new PhantomJSDriver(caps);
String parentUrl=url+links[ca];
driver.get(parentUrl);
checkPageIsReady(driver);
System.out.println(parentUrl);
if(ca==0) {
fw.println("{\""+categories[ca]+"\":[");
}
else {
fw.println("\""+categories[ca]+"\":[");
}
fw.flush();
WebElement e=driver.findElement(By.className("page-select"));
List<WebElement> c=e.findElements(By.tagName("option"));
String pre="/page-";
for(int x=0;x<c.size();x++) {
dri=new PhantomJSDriver(caps);
dri.get(parentUrl+pre+(x+1));
checkPageIsReady(dri);
List<WebElement> products=dri.findElements(By.className("thumb-inner-wrap"));
System.out.println("Size of"+dri.getTitle()+" is: "+products.size());
int nameNotNullCount=0;
int priceNotNullCount=0;
ArrayList<String> names=new ArrayList<>();
ArrayList<String> prices=new ArrayList<>();
ArrayList<String> descriptions=new ArrayList<>();
ArrayList<String> imgs=new ArrayList<>();
int combo=0;
int loopCount=0;
do {
combo=0;
names=new ArrayList<>();
prices=new ArrayList<>();
descriptions=new ArrayList<>();
imgs=new ArrayList<>();
int tempCombo=0;
boolean lastIsNull=false;
for(int y=0;y<products.size();y++) {
String name="";
String description="";
String price="";
String img="";
// int count=0;
// do {
if(products.get(y).findElement(By.className("centered-img-wrap")).findElement(By.tagName("img")).getAttribute("class").equals("image"))
img=products.get(y).findElement(By.className("centered-img-wrap")).findElement(By.tagName("img")).getAttribute("src");
else img="https:"+products.get(y).findElement(By.className("centered-img-wrap")).findElement(By.tagName("img")).getAttribute("data-original");
// count++;
// if(count==51) {
// img=noImg;
// break;
// }
// }while(!img.startsWith("http"));
if(img==null||img.equals("")||img.length()<5)img=noImg;
img="\""+img+"\"";
name=products.get(y).findElement(By.className("details")).findElement(By.className("thumb-header")).getText();
description=products.get(y).findElement(By.className("details")).findElement(By.className("description")).getText();
name=name.replaceAll("\"", "'");
name=name.replaceAll("\r\n", " ");
name=name.replaceAll("\n", " ");
name=name.replaceAll("\r", " ");
name=name.replaceAll("Mr .", "Mr.").replaceAll("Mr. ", "Mr.");
name=removeMarkSymbol(name);
name=replaceUmlaute(name);
if(description.length()>40)description="null";//omit useless long text description
else {
description=description.replaceAll("\"", "'");
description="\""+description+"\"";
}
description=description.replaceAll("\r\n", " ");
description=description.replaceAll("\n", " ");
description=description.replaceAll("\r", " ");
if(ca!=0&&ca!=3) {
price=products.get(y).findElement(By.cssSelector("div[class='price-current']")).getText();
}
else {
price=products.get(y).findElement(By.cssSelector("div[class='price-current width-adjusted']")).getText();
}
if(price.length()>1) {
if(!price.contains("$")) {
price=price.substring(0,price.length()-1);
Double temp=Double.parseDouble(price);
temp=temp/100;
price="$"+temp.toString();
}
price="\""+price+"\"";
}
else {
price="null";
}
names.add(name);
prices.add(price);
descriptions.add(description);
imgs.add(img);
if(!name.equals("")) {
nameNotNullCount++;
}
if(!price.equals("null")) {
priceNotNullCount++;
if(tempCombo>0) {
if(tempCombo>combo)combo=tempCombo;
tempCombo=0;
}
lastIsNull=false;
}
else {
if(lastIsNull) {
tempCombo++;
if(tempCombo>combo)combo=tempCombo;
}
lastIsNull=true;
}
System.out.println(name+" "+description+" "+price);
}
loopCount++;
if(loopCount>100) {
break;
}
}while((products.size()>0&&(nameNotNullCount==0||priceNotNullCount==0))||combo>3);
dri.quit();
for(int y=0;y<products.size();y++) {
String brand="";
brand=getBrand(brands,names.get(y));
if(brand==null) {
brand="null";
}
else if(brand.equals("Oreo")) {//special case for Oreo( it seems should be Christie)
brand="Christie";
if(names.get(y).contains(brand)) {
names.set(y, names.get(y).replace(brand+" ", ""));
}
if(names.get(y).contains("NESTLÉ")) {
names.set(y,names.get(y).replace("NESTLÉ", ""));
}
brand="\""+brand+"\"";
}
else {
//special case for Aquafina 1L & Evian & Dasani & 7UP & Monster Energy
if(names.get(y).equals("Aquafina")||names.get(y).equals("Evian")||names.get(y).equals("Dasani")||names.get(y).equals("7UP")||names.get(y).equals("Monster Energy")) {
if(names.get(y).equals("7UP")) {
names.set(y, "7 UP");
}
else if(names.get(y).equals("Monster Energy")) {
names.set(y, "drink");
}
else {
names.set(y,"water");
}
}
names.set(y, removeBrand(names.get(y),brand));
brand="\""+brand+"\"";
}
if(x==c.size()-1&&y==products.size()-1) {
fw.println("{\"category\":\""+categories[ca]+"\",\"name\":\""+names.get(y)+"\",\"price\":"+prices.get(y)+",\"description\":"+descriptions.get(y)+",\"brand\":"+brand+",\"image\":"+imgs.get(y)+",\"store\":\"Walmart\"}");
}
else {
fw.println("{\"category\":\""+categories[ca]+"\",\"name\":\""+names.get(y)+"\",\"price\":"+prices.get(y)+",\"description\":"+descriptions.get(y)+",\"brand\":"+brand+",\"image\":"+imgs.get(y)+",\"store\":\"Walmart\"},");
}
fw.flush();
}
if(nameNotNullCount==0||priceNotNullCount==0||products.size()==0) {
failUrl.add(parentUrl+pre+(x+1));
}
}
//}
if(ca==categories.length-1) {
fw.println("]}");
}
else {
fw.println("],");
}
fw.flush();
driver.quit();
status=true;
}
}
//check if the page is loaded successfully
public void checkPageIsReady(WebDriver driver) {
JavascriptExecutor js = (JavascriptExecutor)driver;
//Initially bellow given if condition will check ready state of page.
if (js.executeScript("return document.readyState").toString().equals("complete")){
System.out.println("Page Is loaded.");
return;
}
//This loop will rotate for 40 times to check If page Is ready after every 1 second.
for (int i=0; i<40; i++){
try {
Thread.sleep(1000);
}catch (InterruptedException e) {}
//To check page ready state.
if (js.executeScript("return document.readyState").toString().equals("complete")){
break;
}
}
}
//remove mark symbol
public String removeMarkSymbol(String r) {
r = r.replaceAll( "\u00B0" ,"").replaceAll("\u00a9","").replaceAll( "\u00AE" ,"").replaceAll( "\u2122" ,"");
return r;
}
public Walmart() {
status=false;
}
public static void main(String[] args) throws Exception{
int count=0;
Walmart s = null;
// do {
try {
s=new Walmart();
s.execute("D:\\Walmart.json");
}catch(Exception e) {
s.ABdriver.quit();
s.tempDri.quit();
s.dri.quit();
s.driver.quit();
System.out.println("check the file path or internet connection and try again later");
e.printStackTrace();
}
finally {
System.out.println(count+" count "+count);
// TimeUnit.SECONDS.sleep(40);
}
// }while(!Walmart.status);
for(int x=0;x<s.failUrl.size();x++) {
System.out.println(s.failUrl.get(x));
}
}
} | [
"wch4university@gmail.com"
] | wch4university@gmail.com |
a9a4a18153bc34c60b4aa8a33303663703de28f1 | d8b2d050449da8595a0bd36a917ad98edcef4a6e | /src/Constant.java | df2a315efefa9f3e3cf18e35b4ef4fa29f60d607 | [] | no_license | layantha31/Mars_Rover_Challenge | 2d4d07b79cab22d9a7e11d9a9e3e761e1067d260 | 570550c89ffd541281abc28e544418ed6ff34d3f | refs/heads/master | 2023-06-30T18:12:25.267674 | 2021-07-26T04:15:53 | 2021-07-26T04:15:53 | 389,374,064 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 137 | java | public class Constant {
//Replacing four cardinal compass points with integers
static final int N = 1 , E = 3 , S = 5 , W = 7;
}
| [
"66356125+layantha31@users.noreply.github.com"
] | 66356125+layantha31@users.noreply.github.com |
0217e9b019ec44a4dfce94b79c1864ae8ba11609 | 49638690b999020197751d203b521829428a61bc | /app/src/main/java/com/bridgeLabz/bookstore/Model/CartResponseModel.java | 701b2929b3676cc48b871bd45dc93b9873a9ce4d | [] | no_license | pragadaarun/BookStore | 05b1600bb863fc765622aaaf7aa33c98119457e4 | 9a11c5002f48678271b07f2223df2a99ba7d2db5 | refs/heads/main | 2023-06-11T14:50:46.335246 | 2021-06-30T11:51:13 | 2021-06-30T11:51:13 | 373,244,244 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 672 | java | package com.bridgeLabz.bookstore.Model;
public class CartResponseModel {
private int bookId;
private int itemQuantities;
public CartResponseModel() {
}
public CartResponseModel(int bookId, int itemQuantities) {
this.bookId = bookId;
this.itemQuantities = itemQuantities;
}
public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public int getItemQuantities() {
return itemQuantities;
}
public void setItemQuantities(int itemQuantities) {
this.itemQuantities = itemQuantities;
}
}
| [
"pmaniarunkumar@gmail.com"
] | pmaniarunkumar@gmail.com |
295315db0e619834723ac0a217aef14b9c1d6a25 | 45d95ac89334a2758d3d37b3ab83173740413d3e | /DataCom1(hw)/src/datacom1/hw/Com1hw.java | cadbd61fcd0ba5ce1ab70d9f876afa7324ef61bd | [] | no_license | Mirajul-Mohin/Datacom-Lab | 56862cb52e120278591c148cb799a2a4d9f5003e | 9f28d602833e7e036ecfa71241a6688b5e58bada | refs/heads/master | 2020-04-23T18:07:20.855339 | 2019-02-18T21:01:17 | 2019-02-18T21:01:17 | 171,355,462 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,415 | java | package datacom1.hw;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
public class Com1hw {
public static ServerSocket server;
public static Socket client;
public static DataInputStream input;
public static DataOutputStream output;
public static FileWriter fw;
public static void main(String[] args) throws IOException {
server = new ServerSocket(5555);
client = server.accept();
input = new DataInputStream(client.getInputStream());
output = new DataOutputStream(client.getOutputStream());
fw = new FileWriter("output.txt", true);
while(true)
{
int sum=0;
int mod;
String str;
try{
str= input.readUTF();
String[] part;
part=str.split("#");
for(int i = 0 ;i<part[0].length();i++)
{
sum+=part[0].charAt(i);
}
mod=sum%16;
if(mod==Integer.parseInt(part[1]))
{
output.writeUTF("Received");
System.out.println("Successed to Recieve "+str);
fw.write(part[0]);
fw.write(System.getProperty("line.separator"));
fw.flush();
}
else
{
output.writeUTF("Error");
System.out.println("Error Occured");
//continue;
}
}
catch(Exception e){}
//fw.close();
}
}
}
| [
"mohinmirajul@gmail.com"
] | mohinmirajul@gmail.com |
0e26e13de9fb1d56d83d1eb353aeffd8ae48d6ab | 0aaff2f627da5a500af9384f4f5ed9543fc6d88d | /app/src/main/java/com/tz/newlife/module/ui/activity/FruitActivity.java | 3e87b0d2199aa08dc5393e54f82608d08e5f43b6 | [] | no_license | zjiamin/Wxbot | 54d9ed1944522fbe5b063732cadece1e92766695 | 53c5d605df4f56ba13de5d0d6ef7267d20cfb1b6 | refs/heads/master | 2020-03-19T03:05:40.055948 | 2018-07-28T10:51:21 | 2018-07-28T10:51:21 | 135,694,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,397 | java | package com.tz.newlife.module.ui.activity;
import android.content.Intent;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.tz.newlife.R;
import com.tz.newlife.module.base.BaseActivity;
public class FruitActivity extends BaseActivity implements View.OnClickListener {
public static final String FRUIT_NAME = "fruit_name";
public static final String FRUIT_IMAGE_ID = "fruit_image_id";
private AppBarLayout appBarLayout;
private CollapsingToolbarLayout collapsingToolbarLayout;
private ImageView fruit_image_view;
private Toolbar toolbar;
private TextView fruit_content_tv;
private FloatingActionButton fab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fruit);
initView();
initEvent();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true ;
}
protected void initView() {
Intent intent = getIntent();
String fruitName = intent.getStringExtra(FRUIT_NAME);
int fruitImageId = intent.getIntExtra(FRUIT_IMAGE_ID, 0);
appBarLayout = (AppBarLayout) findViewById(R.id.appBar);
collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
fruit_image_view = (ImageView) findViewById(R.id.fruit_image_view);
toolbar = (Toolbar) findViewById(R.id.toolbar);
fruit_content_tv = (TextView) findViewById(R.id.fruit_content_text);
fab = (FloatingActionButton) findViewById(R.id.fab_fruit);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
//因为toolbar的默认图标就是一个返回箭头,因此没有特殊要求的话不用再设置图标了
}
collapsingToolbarLayout.setTitle(fruitName);
Glide.with(this).load(fruitImageId).into(fruit_image_view);
String fruitContent = generateFruitContent(fruitName);
fruit_content_tv.setText(fruitContent);
}
private String generateFruitContent(String fruitName) {
StringBuilder fruitContent = new StringBuilder();
for (int i = 0; i < 500; i++) {
fruitContent.append(fruitName);
}
return fruitContent.toString();
}
private void initEvent() {
fab.setOnClickListener(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.add_item:
Toast.makeText(FruitActivity.this, "Add clicked",
Toast.LENGTH_SHORT).show();
break;
case R.id.remove_item:
Toast.makeText(FruitActivity.this, "Remove clicked",
Toast.LENGTH_SHORT).show();
default:
}
return true;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.fab_fruit:
Snackbar.make(fab, "Data deleted", Snackbar.LENGTH_SHORT)
.setAction("Undo", new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(FruitActivity.this, "Data restored",
Toast.LENGTH_SHORT).show();
}
}).show();
break;
//傻人有傻福,傻逼没有。
}
}
}
| [
"iimouttatime@163.com"
] | iimouttatime@163.com |
a24a3404ebada786ae4891d35682260ef3247e5b | aebad12071d030c9738d7d98903901cd65fe54d3 | /src/main/java/com/tmount/db/order/dto/ReBankAcceptKey.java | d7947f7cc2b37397462444421372abf7a850a2be | [] | no_license | sherryya/sshop_zdc | c0aa335890d1df78117546d1b3fdb7612c7a9750 | 07398d5da64350ffb257d7ec71699eb63a07fe97 | refs/heads/master | 2021-01-22T01:33:53.862482 | 2015-06-11T03:05:24 | 2015-06-11T03:05:24 | 37,116,956 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 423 | java | package com.tmount.db.order.dto;
public class ReBankAcceptKey {
private Long bankAccept;
private Integer orgId;
public Long getBankAccept() {
return bankAccept;
}
public void setBankAccept(Long bankAccept) {
this.bankAccept = bankAccept;
}
public Integer getOrgId() {
return orgId;
}
public void setOrgId(Integer orgId) {
this.orgId = orgId;
}
} | [
"904284211@qq.com"
] | 904284211@qq.com |
85529d3e99c117a9949c9cbbfad30ef100cb90ab | fa1680d1f4e1e090a360cf8771dd3c28fa31ac24 | /CivicHall/src/weekFour/CivicHashMap.java | b014bab947c45ebbdaba499b7446e7959fb0295d | [] | no_license | pdebi7587/JavaBootcamp | 32128f4c3d33ff558d60831aed9ac25b1ce2aabc | 70dc1375bffd8e29f50c110e1fd04a64b0d1af40 | refs/heads/master | 2020-07-07T01:45:43.266845 | 2019-08-19T16:02:50 | 2019-08-19T16:02:50 | 203,204,483 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 161 | java | package weekFour;
public class CivicHashMap {
private int age;
public void setAge(int age) {
this.age = age;
}
public int getAge() {
this.
}
}
| [
"student_113@PSXGA113s-MacBook-Air.local"
] | student_113@PSXGA113s-MacBook-Air.local |
93405a7cdbc86cdaeedb7ce0208ed57f1100e1e1 | f2f1e3a4afd0c1c91516235afb21a057777c7049 | /Projeto -POO/GGForm.java | da94fc93d7c7c6050ce2ed90bd5e3ff2ff8c1040 | [] | no_license | alex-abreu/codes | 74b39c01bc80b32b714e07b89ebb0f2ed1d0b171 | 9ff5a69fa11a80081530a3d78f40a0db9f07cbf3 | refs/heads/master | 2022-08-18T20:05:48.500967 | 2020-05-25T19:02:42 | 2020-05-25T19:02:42 | 266,854,953 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,594 | java | import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Arrays;
public class GGForm {
private JPanel gg_form;
private JTextField user_field;
private JPasswordField pass_field;
private JButton adicionarGerenteButton;
/**fields */
private String name;
private String cpf;
private String rg;
private String adress;
private String clt;
private String da;
GGDash g;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
public GGForm(String name, String cpf, String rg, String addrs, String clt, String da, GGDash g)
{
this.name = name; this.cpf = cpf; this.rg = rg;
this.adress = addrs; this.clt = clt; this.da = da;
this.g = g;
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
gg_form = new JPanel();
gg_form.setLayout(new GridBagLayout());
gg_form.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "Gerente Geral", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-16777216)));
final JLabel label1 = new JLabel();
label1.setText("Usuário");
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gg_form.add(label1, gbc);
user_field = new JTextField();
user_field.setColumns(10);
gbc = new GridBagConstraints();
gbc.gridx = 3;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gg_form.add(user_field, gbc);
final JLabel label2 = new JLabel();
label2.setText("Senha");
gbc = new GridBagConstraints();
gbc.gridx = 5;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gg_form.add(label2, gbc);
pass_field = new JPasswordField();
pass_field.setColumns(10);
gbc = new GridBagConstraints();
gbc.gridx = 7;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gg_form.add(pass_field, gbc);
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridBagLayout());
panel1.setPreferredSize(new Dimension(5, 0));
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gg_form.add(panel1, gbc);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridBagLayout());
panel2.setPreferredSize(new Dimension(10, 0));
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gg_form.add(panel2, gbc);
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridBagLayout());
panel3.setPreferredSize(new Dimension(5, 0));
gbc = new GridBagConstraints();
gbc.gridx = 6;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gg_form.add(panel3, gbc);
final JPanel panel4 = new JPanel();
panel4.setLayout(new GridBagLayout());
panel4.setPreferredSize(new Dimension(0, 10));
gbc = new GridBagConstraints();
gbc.gridx = 5;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.BOTH;
gg_form.add(panel4, gbc);
final JPanel panel5 = new JPanel();
panel5.setLayout(new GridBagLayout());
panel5.setPreferredSize(new Dimension(10, 0));
gbc = new GridBagConstraints();
gbc.gridx = 8;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gg_form.add(panel5, gbc);
final JPanel panel6 = new JPanel();
panel6.setLayout(new GridBagLayout());
panel6.setPreferredSize(new Dimension(10, 0));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gg_form.add(panel6, gbc);
adicionarGerenteButton = new JButton();
adicionarGerenteButton.setText("Adicionar Gerente");
gbc = new GridBagConstraints();
gbc.gridx = 7;
gbc.gridy = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
gg_form.add(adicionarGerenteButton, gbc);
adicionarGerenteButton.addActionListener(new AddGGListener());
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return gg_form;
}
class AddGGListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent ev)
{
System.out.println(name + cpf + rg + adress + clt + da);
Gerente_Geral gg = new Gerente_Geral(name, cpf, rg, adress, clt, da);
String pass = new String(pass_field.getPassword());
//System.out.println("user before: "+user_field.getText().length() +"senha before:"+pass.length());
/**
* validando usario e senha
*/
if(user_field.getText().length() == 0)
{
JOptionPane.showMessageDialog(null,"Usuário em branco!","AVISO",JOptionPane.WARNING_MESSAGE);
return;
}
if(pass.length() == 0)
{
JOptionPane.showMessageDialog(null,"Senha em branco!","AVISO",JOptionPane.WARNING_MESSAGE);
return;
}
Usuario u = new Usuario(user_field.getText(), pass);
System.out.println("user: "+u.getUsuario() +"senha:"+u.getSenha());
Object[] data = {u.getUsuario(), u.getSenha(),"Gerente Geral"};
if(u.cadastraUsuario(gg) != -1)
{
JOptionPane.showMessageDialog(null, "Usuário "+ u.getUsuario() + " Já cadastrado!.");
return;
}
Usuarios.addUsuario(u);
g.users_model.addRow(data);
g.users_table.clearSelection();
g.users_model.fireTableDataChanged();
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
baa6619a4b5c4a570d49974396dfa5d6469f287a | baf22f16346c66170f0f014451d24f0a3d7db9a4 | /resys-one-server/src/main/java/xmt/resys/user/dao/UserDao.java | d263365fc6a3a7ef088a16aeccbea29741b8475b | [
"MIT"
] | permissive | wangyaomail/resys-one | d09f46b01aa35955eaec65910e86d4e894b93e0a | c43d4dc894e8fb86416425967844784d06d16952 | refs/heads/master | 2022-08-26T20:48:59.338122 | 2022-08-23T02:39:52 | 2022-08-23T02:39:52 | 216,051,884 | 17 | 4 | null | 2021-11-27T02:10:05 | 2019-10-18T15:14:33 | Java | UTF-8 | Java | false | false | 1,197 | java | package xmt.resys.user.dao;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import xmt.resys.common.dao.l3.BaseMongoDao;
import xmt.resys.user.bean.mongo.HBUser;
@Repository("userDao")
public class UserDao extends BaseMongoDao<HBUser> {
public HBUser findUserByNameAndPwd(String username,
String password) {
Query query = new Query();
Criteria c1 = Criteria.where("name").is(username);
Criteria c2 = Criteria.where("password").is(password);
query.addCriteria(new Criteria().andOperator(c1, c2));
return mongoTemplate.findOne(query, getClassT(), getCollectionName());
}
public HBUser findUserById(String id) {
return findOne(id);
}
public HBUser findUserByName(String name) {
return mongoTemplate.findOne(new Query(Criteria.where("userName").is(name)),
getClassT(),
getCollectionName());
}
public HBUser insert(HBUser object) {
return super.insert(object);
}
}
| [
"wangyao@helper12366.com"
] | wangyao@helper12366.com |
c3d48d0e42466250c6723bb92dbf567fd4997ba8 | 377d6fee6e5589b627228ab0e27f05100a6178b4 | /Algorithm/src/main/java/com/liyafeng/algorithm/basic/sort/N_Sort_InsertionSort.java | dc6abfbf4021ccc66fb18dce22e00bdd3dc43cb3 | [
"Apache-2.0"
] | permissive | lvfeimeng/BestPracticeApp | fecff03d239e9421f3ef753a4c0bbde3c602b6d4 | 35aaedea6ea2b611923628dccd8a5f38d7a07f06 | refs/heads/master | 2020-03-25T02:19:08.070726 | 2018-08-02T09:32:24 | 2018-08-02T09:32:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,050 | java | package com.liyafeng.algorithm.basic.sort;
/**
* Created by liyafeng on 2018/2/12.
*/
public class N_Sort_InsertionSort {
/**
* 插入排序(平均需要n^2/4次比较和n^2/4次交换
* 最坏情况是逆序数组,需要n^2/2次比较和n^2/2次交换
* 最好情况是正序数组,需要n-1次比较和0次交换)
* 时间复杂度:O(n^2)
* ================原理================
* 从第二个元素开始,插入前面已经排序好的数组
* 依次和前面元素比较,小于就交换,直到大于停止内循环
*
* @param args
*/
public static void main(String[] args) {
int[] array = {1, 124, 54, 34, 34, 6, 5};
sort(array);
Util.print(array);
}
private static void sort(int[] array) {
for (int i = 1; i < array.length; i++) {
for (int j = i; j > 0 && array[j] < array[j - 1]; j--) {//依次插入之前已排序好的元素中
Util.exchange(array, j, j - 1);
}
}
}
}
| [
"859405648@qq.com"
] | 859405648@qq.com |
361dcf0b906c34e613d2defe0589ccf325e23a84 | cca87c4ade972a682c9bf0663ffdf21232c9b857 | /com/tencent/mm/modelfriend/g.java | 84d05a2a2aa7bd1aaae6999e7908892eca0be419 | [] | no_license | ZoranLi/wechat_reversing | b246d43f7c2d7beb00a339e2f825fcb127e0d1a1 | 36b10ef49d2c75d69e3c8fdd5b1ea3baa2bba49a | refs/heads/master | 2021-07-05T01:17:20.533427 | 2017-09-25T09:07:33 | 2017-09-25T09:07:33 | 104,726,592 | 12 | 1 | null | null | null | null | UTF-8 | Java | false | false | 538 | java | package com.tencent.mm.modelfriend;
import com.tencent.mm.e.a.fh;
import com.tencent.mm.sdk.b.b;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.bg;
public final class g extends c<fh> {
public g() {
this.usg = fh.class.getName().hashCode();
}
public final /* synthetic */ boolean a(b bVar) {
fh fhVar = (fh) bVar;
fhVar.fJS.fJT = m.jh(fhVar.fJR.fJO);
if (bg.mA(fhVar.fJS.fJT)) {
fhVar.fJS.fJT = m.jh(fhVar.fJR.fJP);
}
return false;
}
}
| [
"lizhangliao@xiaohongchun.com"
] | lizhangliao@xiaohongchun.com |
91e04e791ea7cc0e8ece21b85ae104f5262b509f | 1f2f2abf0b14d402fb937693d9facd8fb5cdd11e | /src/main/java/com/sikorski/weatherapp/aggregator/aggregation/domain/model/elements/WeatherUnit.java | e6b61dc4dd2a336fddd6a09c0bde4660a9769800 | [] | no_license | jasphall/WeatherAggregator | aeec3ca42d384600f59c0faaf1344816cbb62af9 | 64d42fe8d1788c08dcd96583debe27f671b42871 | refs/heads/master | 2021-01-25T06:24:59.355550 | 2017-07-11T19:32:55 | 2017-07-11T19:32:55 | 93,568,577 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 918 | java | package com.sikorski.weatherapp.aggregator.aggregation.domain.model.elements;
import com.sikorski.weatherapp.aggregator.aggregation.domain.model.persistence.WeatherDataModel;
import com.sikorski.weatherapp.aggregator.application.persistence.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "WeatherUnits")
@NoArgsConstructor
@AllArgsConstructor
@Data
public class WeatherUnit extends BaseEntity {
private String value;
private String unit;
@ManyToOne
private WeatherDataModel weatherDataModel;
public static WeatherUnit of(String value, String unit) {
return new WeatherUnit(value, unit);
}
private WeatherUnit(String value, String unit) {
this.value = value;
this.unit = unit;
}
}
| [
"maciekksikorski@gmail.com"
] | maciekksikorski@gmail.com |
fde538c6754d67f977195fd37c66fe48e39782be | bbbfdd01d3154510e90b90ad08ae3935d7e368e9 | /src/programmers/level1/두개뽑아서더하기.java | 9f66c4102df2a1d4aa69dcf78193af61400ead99 | [] | no_license | yujeong0/AlgoProb | 9570d61e3223c86929262fb021ab5f8c07b02952 | 9141d31e6451dd8cbeaa65de9988950c3a5a87c9 | refs/heads/master | 2023-08-01T02:53:33.007870 | 2021-09-06T13:19:47 | 2021-09-06T13:19:47 | 288,496,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 827 | java | package programmers.level1;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class 두개뽑아서더하기 {
public int[] solution(int[] numbers) {
Set<Integer> set = new HashSet<>();
for (int i = 0; i < numbers.length; i++) {
for (int j = i+1; j < numbers.length; j++) {
set.add(numbers[i] + numbers[j]);
}
}
int[] answer = new int[set.size()];
Iterator iter = set.iterator();
int i = 0;
while(iter.hasNext()) {
answer[i++] = (int) iter.next();
}
Arrays.sort(answer);
return answer;
}
public static void main(String[] args) {
new 두개뽑아서더하기().service();
}
public void service() {
System.out.println(Arrays.toString(solution(new int[] {2,1,3,4,1})));
}
}
| [
"kos9811@naver.com"
] | kos9811@naver.com |
427feac4f54371655e203481fef723bbc9f0a139 | 98e654e97b71a7d937dd512073fc1d05170a1a7d | /week_08/day_5/homework/src/test/java/ClassTests/EmployeeTest.java | 60bc1d1b966f7ec78afaac66cf43a150e94613e5 | [] | no_license | edostler/codeclan_classwork | bfd980cc32e4ab649d392d0e9dc54189b9eded1f | 6486a5b981e7d8f6d45f14462dad74298ae75758 | refs/heads/master | 2020-03-17T19:34:17.058501 | 2018-05-17T21:11:11 | 2018-05-17T21:11:11 | 133,868,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,018 | java | package ClassTests;
import models.*;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class EmployeeTest {
private Manager manager;
private Player player;
private Team team;
private Competition competition;
@Before
public void before() {
competition = new Competition("Premier League 5s");
team = new Team("Newcastle United", "St James' Park", competition);
player = new Player("Alan Shearer", 41, team, PositionType.STRIKER, 9);
manager = new Manager("Sir Bobby Robson", 82);
}
@Test
public void canGetPlayerName() {
assertEquals("Alan Shearer", player.getName());
}
@Test
public void canGetManagerName() {
assertEquals("Sir Bobby Robson", manager.getName());
}
@Test
public void canGetPlayerAge() {
assertEquals(41, player.getAge());
}
@Test
public void canGetManagerAge() {
assertEquals(82, manager.getAge());
}
}
| [
"edward.o@simul8.com"
] | edward.o@simul8.com |
a0f2d8870e7c82bb6b3020531c6db3377c6f0d60 | 41dc7d5206013e300a089fc002c7091253ec1a87 | /unit04/task02.java | 09288293a093d973106b83e8792f5223369ea14f | [] | no_license | OSmol/Java-Basics-1 | bba11185cd1ffc5363b9f688e73621233bd42032 | aa20842577655bd701c4174d7720994965157f8c | refs/heads/master | 2022-11-05T00:57:27.546884 | 2020-06-30T10:48:01 | 2020-06-30T10:48:01 | 274,632,728 | 0 | 0 | null | 2020-06-24T09:47:20 | 2020-06-24T09:47:19 | null | UTF-8 | Java | false | false | 1,007 | java | package unit04;
import java.util.Scanner;
public class task02 {
public static void main(String arg[]) {
int a = GetA();
int b = GetB();
int s = GetSFromConsole(a, b);
int c = GetC(a, b);
GetAnswer(c, s);
}
public static int GetSFromConsole(int a, int b) {// getSFromConsole - это Java, а не C#)
System.out.println("Реши пример: " + a + " * " + b + " =");
Scanner scs = new Scanner(System.in);
int s = scs.nextInt();
return s;
}
public static int GetC(int a, int b) {
int c = a * b;
return c;
}
public static int GetA() {
int a = (int) (1 + Math.random() * 9);
return a;
}
public static int GetB() {
int b = (int) (1 + Math.random() * 9);
return b;
}
public static void GetAnswer(int c, int s) {
if (c == s) {
System.out.println("у ти умничка");
} else {
System.out.println("все очень плохо, парень");
}
}
}
// задачи модуля 4 зачтены
| [
"noreply@github.com"
] | noreply@github.com |
7367072d4dd08dd2ecbe5c66dcd01600758ae9c6 | 4795b64885dc752bb03952e5e34be26640187943 | /commonality/proxyPattern/Proxy.java | bde81aca2bc140b5250619878eb877ef7844edfc | [] | no_license | looowoool/Pattern | 7bd180313ee3c710a1a0304d7c69b5f6808d7df0 | 6653a8e2cc01f7941c43afb3b719d33d9be35eff | refs/heads/master | 2021-07-20T18:04:23.556140 | 2017-10-30T02:51:43 | 2017-10-30T02:51:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 700 | java | package com.rxjava.commonality.proxyPattern;
/**
* 作者:wanglei on 17/10/26 11:20
* 邮箱:229846388@qq.com
* 代理模式
* 创建代理对象类(Proxy),即”代购“,并通过代理类创建真实对象实例并访问其方法
*/
public class Proxy implements Subject{
@Override
public void buyMac() {
//引用并创建真实对象实例,即”我“
RealSubject realSubject = new RealSubject();
//调用真实对象的方法,进行代理购买Mac
realSubject.buyMac();
//代理对象额外做的操作
this.WrapMac();
}
private void WrapMac(){
System.out.println("用盒子包装好Mac");
}
}
| [
"noreply@github.com"
] | noreply@github.com |
7d70072fd1600bdebf68f23efdeae89c9b56aa4a | 7a0899b7d82ee3850e99477a9def55482b25f7b4 | /SUPERMARKET/supermarket system/src/details.java | 83e2b368217896340ff554cb15ddb57dee59b4b9 | [] | no_license | kevo-cloud/SupermarketSystem | c8863b772f37315d21f3133650d9147808ad5f4e | 306cce0265a0ea18442341aec7d101543ff1e260 | refs/heads/main | 2023-05-05T06:15:46.330498 | 2021-05-24T09:12:45 | 2021-05-24T09:12:45 | 370,292,472 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,793 | 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.
*/
/**
*
* @author KEVOKE
*/
public class details extends javax.swing.JFrame {
/**
* Creates new form details
*/
public details() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton1.setText("CASHIER");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton2.setText("PRODUCTS");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton3.setText("INVENTORY");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton4.setText("BILL");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton5.setText("BACK");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setText("KELVIN SUPERMARKET");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(101, 101, 101)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(330, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(39, 39, 39)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 55, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(36, 36, 36)
.addComponent(jButton2)
.addGap(31, 31, 31)
.addComponent(jButton3)
.addGap(29, 29, 29)
.addComponent(jButton4)
.addGap(53, 53, 53)
.addComponent(jButton5)
.addGap(40, 40, 40))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
cashier ingia=new cashier();
ingia.setVisible(true);
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
product ingia=new product();
ingia.setVisible(true);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
inventory ingia=new inventory();
ingia.setVisible(true);
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
bill ingia=new bill();
ingia.setVisible(true);
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
login ingia=new login();
ingia.setVisible(true);
}//GEN-LAST:event_jButton5ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new details().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
| [
"noreply@github.com"
] | noreply@github.com |
e803cadcde764c5b8a07cd65659131171178daaa | c41afa996fa843125571f693f7eeb3245226053c | /samples/spring-cloud-connector-postgresql-test/src/main/java/org/terrence/testapp/rest/TestRestController.java | 6921057ec2acabdf31ef92aad4657cd20fb81e28 | [
"Apache-2.0"
] | permissive | IBM-Cloud/bluemix-cloud-connectors | 9b000503cb6204d4f315eda4c997f44d06cd1196 | f16c000cd395040f4e0ac1f9a1a6212de1971e67 | refs/heads/master | 2023-08-22T01:07:03.899217 | 2019-05-07T14:28:03 | 2019-05-07T14:28:03 | 30,895,957 | 4 | 9 | Apache-2.0 | 2019-06-26T04:47:47 | 2015-02-17T00:35:50 | Java | UTF-8 | Java | false | false | 3,593 | java | package org.terrence.testapp.rest;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.terrence.testapp.domain.Person;
import org.terrence.testapp.repositories.PersonRepository;
@RestController
public class TestRestController {
@Autowired
private PersonRepository repo;
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Person test = new Person("TestPerson", 33); // test person object with name and age
String id = UUID.randomUUID().toString(); // use a random id
// test methods
// create test object with random id and fixed name and age
private void createTestObject() throws Exception {
try {
pw.println("Name of the test object is: '" + test.getName() + "'");
pw.println("Age of the test objec is: '" + test.getAge() + "'");
pw.println("Random repo id of the test object is: '" + id + "'");
pw.println("Setting id for test object: '" + id + "'");
test.setId(id);
} catch (Exception e) {
pw.println("FAIL: Unexpected error during create test object.");
e.printStackTrace(pw);
throw e;
}
}
// verify there is nothing in the repo with the id and then create the test
// object
private void addTestObject() throws Exception {
try {
pw.println("Testing for existing id in the repo '" + id + "' and deleting as required.");
// if there is an existing Person with the id then delete it
repo.findById(id).ifPresent(p -> repo.deleteById(p.getId()));
pw.println("Saving test object with id: '" + id + "'");
repo.save(test);
} catch (Exception e) {
System.out.println("Exception caught: creating new object");
pw.println("Saving test object with id: '" + id + "'");
repo.save(test);
throw e;
}
}
// validate the the test object is in the database with the correct id and
// message
private void validateTestObject() throws Exception {
try {
// retrieve check object from the repo with the same id as the test object
Person check = repo.findById(id).get();
// validate the id and message of the check object equals the test object's
pw.println("Validating object in the repo.");
if (((check.getId() == null && test.getId() == null)
|| (check.getId() != null && check.getId().equals(test.getId())))
&& ((check.getName() == null && test.getName() == null)
|| (check.getName() != null && check.getName().equals(test.getName())))) {
pw.println("PASS: Retrieved object in the repo matced the saved object.");
pw.println("Deleting object in the repo.");
repo.deleteById(id);
} else {
pw.println("FAIL: Retrieved object in the repo did NOT match the saved object");
pw.println("Deleting object in the repo.");
repo.deleteById(id);
}
} catch (Exception e) {
pw.println("FAIL: Problem during retrieve of object...");
e.printStackTrace(pw);
throw e;
}
}
// run the test
@RequestMapping(value = "/test", produces = "text/plain")
public String runTest() {
try {
pw.println("Beginning test...");
createTestObject();
addTestObject();
validateTestObject();
} catch (Exception e) {
pw.println("Failure reported by previous method.");
}
pw.flush();
return sw.toString();
}
} | [
"tnixa@us.ibm.com"
] | tnixa@us.ibm.com |
cd2f0df79a24701da7d6804b3e2d559f0ee900ec | 5d5c2688698a2d6689c1d635724b550b31224c86 | /extlib/lwp/product/runtime/eclipse/plugins/com.ibm.domino.calendar.store/src/com/ibm/domino/calendar/store/DeclineAction.java | af616cda1c99ed2e7503bba92dfe5a9c880bf9fb | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-other-permissive",
"MIT",
"CDDL-1.1",
"LicenseRef-scancode-public-domain"
] | permissive | OpenNTF/XPagesExtensionLibrary | 6bffba4bd5eab5b148a3b4d700da244aab053743 | 25b3b1df7fafb7ceb131e07ade93de5c9ff733d5 | refs/heads/master | 2020-04-15T16:12:15.910509 | 2020-03-11T11:49:17 | 2020-03-11T11:49:17 | 26,643,618 | 21 | 35 | Apache-2.0 | 2019-03-25T12:55:44 | 2014-11-14T15:08:35 | Java | WINDOWS-1252 | Java | false | false | 1,021 | java | /*
* © Copyright IBM Corp. 2012
*
* 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.ibm.domino.calendar.store;
public class DeclineAction extends Action {
private Boolean _keepInformed; // null means use user's default
/**
* @return the keepInformed
*/
public Boolean getKeepInformed() {
return _keepInformed;
}
public DeclineAction(String comments, Boolean keepInformed) {
super(Action.ACTION_DECLINE, comments);
_keepInformed = keepInformed;
}
}
| [
"padraic.edwards@ie.ibm.com"
] | padraic.edwards@ie.ibm.com |
f073c3d7a29bc56888723e993c86e7d4f9a9668a | a42fe16db75d63699ccbc5789531f2bb0d30eec2 | /src/pangMoleGameModel/Monkey.java | a2d5ed74da2e49a73cdf85418eb96f4821bb0411 | [] | no_license | ppsis14/Pang-Mole-Game | e27007fbaa1e95a570b35974037f82a75bd5c1ed | 5bd1f8dabb332c78f320a11a0b85dd245dac7b46 | refs/heads/master | 2020-04-17T07:27:00.322561 | 2019-01-18T08:20:08 | 2019-01-18T08:20:08 | 166,367,690 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,337 | java | package pangMoleGameModel;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.ArcType;
public class Monkey extends Animals {
private Color tissueMonkeyColor;
/**
* @param x is position X of monkey on pane.
* @param y is position Y of monkey on pane.
*/
public Monkey(double x, double y) {
setTranslateX(x);
setTranslateY(y);
setHeight(200);
setWidth(100);
tissueMonkeyColor = Color.rgb(221, 209, 179);
}
@Override
public void draw() {
super.draw();
drawBananaInHand();
}
@Override
public void drawBody() {
GraphicsContext monkeyBody = getGraphicsContext2D();
Stop[] stopMonkey = new Stop[] { new Stop(0, Color.rgb(139,85,35)), new Stop(1, Color.rgb(155,140,42))};
LinearGradient linearGradientMonkey = new LinearGradient(0, 0, 0, 2, true, CycleMethod.NO_CYCLE, stopMonkey);
monkeyBody.setFill(linearGradientMonkey);
//tail
monkeyBody.fillOval(47,15,15,16);
monkeyBody.strokeOval(47,15,15,16);
monkeyBody.setFill(Color.rgb(135,140,131));
monkeyBody.fillOval(47,19,13,7);
monkeyBody.strokeOval(47,19,13,7);
monkeyBody.setFill(linearGradientMonkey);
monkeyBody.fillRoundRect(48, 15, 6, 50, 10, 10);
monkeyBody.strokeRoundRect(48, 15, 6, 50, 10, 10);
//legs
monkeyBody.fillRoundRect(28, 40, 8, 20, 20, 20);
monkeyBody.strokeRoundRect(28, 40, 8, 20, 20, 20);
monkeyBody.fillRoundRect(65, 40, 8, 20, 20, 20);
monkeyBody.strokeRoundRect(65, 40, 8, 20, 20, 20);
//feet
monkeyBody.setFill(tissueMonkeyColor);
monkeyBody.fillArc(17, 32, 20, 12, 0, -180, ArcType.ROUND);
monkeyBody.fillArc(63, 32, 20, 12, 0, -180, ArcType.ROUND);
monkeyBody.strokeArc(17, 32, 20, 12, 0, -180, ArcType.ROUND);
monkeyBody.strokeArc(63, 32, 20, 12, 0, -180, ArcType.ROUND);
//arms
monkeyBody.setFill(linearGradientMonkey);
monkeyBody.fillRoundRect(30, 130, 10, 30, 20, 20);
monkeyBody.strokeRoundRect(30, 130, 10, 30, 20, 20);
monkeyBody.fillRoundRect(63, 130, 10, 30, 20, 20);
monkeyBody.strokeRoundRect(63, 130, 10, 30, 20, 20);
//hands
monkeyBody.setFill(tissueMonkeyColor);
monkeyBody.fillOval(30, 154, 15, 12);
monkeyBody.strokeOval(30, 154, 15, 12);
monkeyBody.fillOval(58, 154, 15, 12);
monkeyBody.strokeOval(58, 154, 15, 12);
//body
monkeyBody.setFill(linearGradientMonkey);
monkeyBody.fillRoundRect(30, 50, 40, 50, 40, 40);
monkeyBody.strokeRoundRect(30, 50, 40, 50, 40, 40);
//left outer ears
monkeyBody.fillOval(5,95,20,20);
monkeyBody.strokeOval(5,95,20,20);
//right outer ears
monkeyBody.fillOval(75,95,20,20);
monkeyBody.strokeOval(75,95,20,20);
//inner ears
monkeyBody.setFill(tissueMonkeyColor);
//left
monkeyBody.fillOval(10,98,15,13);
monkeyBody.strokeOval(10,98,15,13);
//right
monkeyBody.fillOval(75,98,15,13);
monkeyBody.strokeOval(75,98,15,13);
//head
monkeyBody.setFill(linearGradientMonkey);
monkeyBody.fillOval(20, 85, 60,55);
monkeyBody.strokeOval(20, 85, 60,55);
}
@Override
public void drawFace() {
GraphicsContext monkeyFace = getGraphicsContext2D();
//face frame
monkeyFace.setFill(Color.rgb(221, 209, 179));
monkeyFace.fillOval(30, 93, 25,35);
monkeyFace.fillOval(45, 93, 25,35);
monkeyFace.fillOval(27, 105, 47,30);
//eye left
monkeyFace.setFill(Color.BLACK);
monkeyFace.fillOval(30, 100, 15, 15);
monkeyFace.setFill(Color.WHITE);
monkeyFace.fillOval(33, 103, 5, 5);
monkeyFace.fillOval(37, 110, 2, 2);
// eye right
monkeyFace.setFill(Color.BLACK);
monkeyFace.fillOval(55, 100, 15, 15);
monkeyFace.setFill(Color.WHITE);
monkeyFace.fillOval(61, 103, 5, 5);
monkeyFace.fillOval(58, 110, 2, 2);
// nose
monkeyFace.setFill(Color.rgb(202, 153, 114));
monkeyFace.fillOval(47, 115, 7, 4);
monkeyFace.strokeOval(47, 115, 7, 4);
//cheek
monkeyFace.setFill(Color.rgb(214, 130, 173, 0.302));
monkeyFace.fillOval(32, 119, 10, 7);
monkeyFace.fillOval(60, 119, 10, 7);
//mouth
monkeyFace.setFill(Color.rgb(202, 153, 114));
monkeyFace.fillOval(46, 123, 10, 13);
monkeyFace.strokeOval(46, 123, 10, 13);
monkeyFace.setFill(Color.rgb(214, 89, 88));
monkeyFace.fillOval(48.5, 126, 5, 7);
}
private void drawBananaInHand(){
GraphicsContext banana = getGraphicsContext2D();
Stop[] stopBanana = new Stop[] { new Stop(0, Color.rgb(250,244,66)), new Stop(1, Color.rgb(226,204,64))};
LinearGradient linearGradientBanana = new LinearGradient(0, 0, 2, 2, true, CycleMethod.NO_CYCLE, stopBanana);
//banana 1
banana.setFill(linearGradientBanana);
banana.fillRoundRect(77, 145, 10, 5, 10, 10);
banana.strokeRoundRect(77, 145, 10, 5, 10, 10);
banana.fillArc(33, 135, 45, 25, 20, -180, ArcType.CHORD);
banana.strokeArc(33, 135, 45, 25, 20, -180, ArcType.CHORD);
banana.strokeLine(43,155, 70, 150);
banana.setFill(Color.BLACK);
banana.fillOval(33, 150, 5,6);
//banana 2
banana.setFill(linearGradientBanana);
banana.fillRoundRect(82, 140, 7, 25, 10, 10);
banana.strokeRoundRect(82, 140, 7, 25, 10, 10);
banana.fillRoundRect(77, 155, 10, 5, 10, 10);
banana.strokeRoundRect(77, 155, 10, 5, 10, 10);
banana.fillArc(28, 145, 50, 25, 20, -180, ArcType.CHORD);
banana.strokeArc(28, 145, 50, 25, 20, -180, ArcType.CHORD);
banana.strokeLine(38,165, 70, 160);
banana.setFill(Color.BLACK);
banana.fillOval(28, 160, 5,6);
}
public void goRight(){ setTranslateX(getTranslateX() + 1); }
public void goLeft(){ setTranslateX(getTranslateX() - 1); }
}
| [
"thikamporn.s@ku.th"
] | thikamporn.s@ku.th |
1decdee159e4702c28be1fc5c5188751126cd209 | 5f39e1d320322bbdf2c3630bca8b4abc8eabc9d9 | /src/main/java/com/qm/nettylearn/protocol/codec/MarshallingDecoder.java | 80c590a511b3b581d0f5629642e320ee016db2c6 | [] | no_license | Mengnancy/DelayTest | 4fa82b790d95c18b64d1b85b386a0b10c7648a28 | 4ce6d6774cf8a47b3f01047d8ad870e3d25a8a53 | refs/heads/master | 2020-04-08T04:43:36.593886 | 2018-12-28T15:45:39 | 2018-12-28T15:45:39 | 159,029,221 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,000 | java | package com.qm.nettylearn.protocol.codec;
import io.netty.buffer.ByteBuf;
import org.jboss.marshalling.ByteInput;
import org.jboss.marshalling.Unmarshaller;
import java.io.IOException;
/**
* @Author: Linglingxin
* @Date: 2018/12/3 23:00
*/
public class MarshallingDecoder {
private final Unmarshaller unmarshaller;
public MarshallingDecoder() throws IOException {
this.unmarshaller = MarshallingCodecFactory.buildUnMarshalling();
}
protected Object decode(ByteBuf in) throws IOException, ClassNotFoundException {
int objectSize = in.readInt();
ByteBuf buf = in.slice(in.readerIndex(), objectSize);
ByteInput input = new ChannelBufferByteInput(buf);
try {
unmarshaller.start(input);
Object obj = unmarshaller.readObject();
unmarshaller.finish();
in.readerIndex(in.readerIndex() + objectSize);
return obj;
} finally {
unmarshaller.close();
}
}
}
| [
"qmyanyu@126.com"
] | qmyanyu@126.com |
9230e1c376f15d43ee04b3ff6e24dcea169fa452 | 89ad81940f33489950aeaeee196764b5b3152384 | /app/src/main/java/com/example/chris/messengerapp/Messenger.java | 577766407bf8924d648b5f82bfd518727371bc9d | [] | no_license | hoehnc/MessengerApp | b2abff5cb8804c17c829c16474565b2313b4f141 | ffdea4413ebc79fcc644d3ae95a748ba697c11f6 | refs/heads/master | 2020-09-21T20:36:17.390095 | 2016-10-09T02:01:54 | 2016-10-09T02:01:54 | 67,761,737 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 795 | java | package com.example.chris.messengerapp;
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class Messenger extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_messenger);
}
public void onSendMessage(View view) {
EditText messageView = (EditText)findViewById(R.id.message);
String messageText = messageView.getText().toString();
Intent intent = new Intent(this, ReceiveMessageActivity.class);
intent.putExtra(ReceiveMessageActivity.EXTRA_MESSAGE, messageText);
startActivity(intent);
}
}
| [
"choehn@ltu.edu"
] | choehn@ltu.edu |
e5989bd85a33223e35d53ce0a84e180099a820fc | f2e6ac1757f4c88392c6e13d377e303d9e90a6d4 | /constructor.java | 4bc2b71cc6e6a94095b65d894d7729ca0134d01f | [] | no_license | lescobara/java | 1c1149a6f9a2121462c11117ccf434eaff2b3d2d | 0b786d5a5c50bf950eb5e65a0bd5a93bedf399e6 | refs/heads/master | 2021-06-18T17:55:34.111917 | 2021-03-11T23:37:11 | 2021-03-11T23:37:11 | 169,645,799 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,448 | java | public class Coordenadas {
private int x,y;//Atributos
public Coordenadas (int x1 , int y1)//constructor
{
//asignamos esos valores
x=x1;
y=y1;
}
public double Distancia (int x1, int y1)
{
//este método recibe como parametros
//las coordenadas del segundo punto
double D;
D=Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
return D;//Retornamops el valor de la distancia
}
public void Pmedio(int x1, int y1)
{
double p1, p2;
p1=(x+x1)/2;
p2=(y+y1)/2;
System.out.println("El puntomedio es: "+p1+","+p2);
}
}
/*Archivo UsaCoordenadas.java*/
public class UsaCoordenadas {
public static void main (String args []){
Coordenadas P=new Coordenadas (10,20);
//calculamos la Distancia:
System.out.println("La Distancia es: "+P.Distancia(5,6));
//Punto Medio
P.Pmedio(5,6);
}
}
/*Tomado de http://programandoenjava.over-blog.es/article-32829724.html*/
| [
"noreply@github.com"
] | noreply@github.com |
eeae7b3410af32fadce9a3c5d368d066ff4a012c | c93d96faacb5cccbae6ed17d6968fc0a45600b93 | /microservice/src/main/java/com/fiorano/openesb/microservice/launch/impl/CoreConstants.java | 780df367b22ccdbc1aa6b78e09470448785ad333 | [] | no_license | prathew/repo1 | 553fe037228187d3a1980e89e57cbe948bba041d | 32ccc588033783f0f734279cdaf60e01015afb05 | refs/heads/master | 2021-01-20T02:37:34.806025 | 2016-03-27T11:27:07 | 2016-03-27T11:27:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,528 | java | /**
* Copyright (c) 1999-2007, Fiorano Software Technologies Pvt. Ltd. and affiliates.
* Copyright (c) 2008-2014, Fiorano Software Pte. Ltd. and affiliates.
* <p>
* All rights reserved.
* <p>
* This software is the confidential and proprietary information
* of Fiorano Software ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* enclosed with this product or entered into with Fiorano.
* <p>
* Created by chaitanya on 22-02-2016.
*/
/**
* Created by chaitanya on 22-02-2016.
*/
package com.fiorano.openesb.microservice.launch.impl;
public interface CoreConstants
{
public final static String NAME_DELIMITER = "__";
public final static String EVENT_PROCESS_REGISTRATION_PREFIX = "Fiorano.Esb.Peer.Core:ServiceType=EventProcess,Name=";
public final static String BUSINESS_COMPONENT_REGISTRATION_PREFIX = "Fiorano.Esb.Peer.Core:ServiceType=BusinessComponent,Name=";
public final static String SYSTEM_ID_PREFIX = "ESBX__SYSTEM";
public final static String SERVICE_PROVIDER_CF = "serviceprovidercf";
public final static String CONFIGURATION_FILE_NAME = "tifosi.cfg";
public final static String STARTUP_CONFIGURATION_FILE_NAME = "tifstartup.cfg";
public final static String APPLICATION_CLOSED_CONNECTION = "APPLICATION_CLOSED_CONNECTION";
public final static String APP_VERSION_DELIM = ":";
public final static String NOT_AVAILABLE = "Not Available";
} | [
"chaitanyakcs@gmail.com"
] | chaitanyakcs@gmail.com |
4d411e9d3f96ee6dff231613c361cf496d09568a | 8f69f0376bef2d9b364c902d9ed56e77a828d1ee | /src/main/java/org/gnuhpc/interview/designpattern/company/Role.java | 414d4021df84820117e7fa25f42e3c6d235ee9b4 | [] | no_license | datainsect/All-About-SDE-Interview | 58a3e803374355026b2c8fc8670f49509ef5e4e5 | 1114e0445be28ebda4228ea4dd190121317092b3 | refs/heads/master | 2022-05-28T23:11:13.180353 | 2020-04-22T06:27:26 | 2020-04-22T06:27:26 | 259,385,255 | 0 | 3 | null | 2020-04-27T16:13:42 | 2020-04-27T16:13:41 | null | UTF-8 | Java | false | false | 98 | java | package org.gnuhpc.interview.designpattern.company;
public interface Role {
void doWork();
}
| [
"gnuhpc@gmail.com"
] | gnuhpc@gmail.com |
37bc7eadb9a97a8c2cd37888c4d6e6e9b48d2216 | 92093632bac744eb18d2f6900f9f87684638967c | /src/main/java/com/revature/views/offer/OfferListView.java | f8801cf6a3a8c9eaf90ad845420116d8c77e19db | [] | no_license | 1906jun10java/Cody-Wilber-p0 | 5fe2e38e1f27ffa8968f2ee0063a27accd8b41d8 | c363dc3a8fbc129836a6cb6728ddbf872ef92d5c | refs/heads/master | 2020-06-10T02:45:35.554737 | 2019-07-07T18:33:01 | 2019-07-07T18:33:01 | 193,559,218 | 0 | 0 | null | 2019-07-06T18:18:56 | 2019-06-24T18:35:25 | null | UTF-8 | Java | false | false | 1,510 | java | package com.revature.views.offer;
import com.revature.beans.Offer;
import com.revature.services.CarService;
import com.revature.services.OfferService;
import java.math.RoundingMode;
import java.util.InputMismatchException;
import java.util.Scanner;
public class OfferListView {
private static OfferService os = OfferService.getInstance();
private static CarService cs = CarService.getInstance();
private static Scanner sc = new Scanner(System.in);
public OfferListView() {}
public void display() {
Integer carId = getCarIdInput();
System.out.println();
System.out.println("Offers for " + carId + ":\n");
for (Offer o : os.getOffersByCar(carId)) {
System.out.println("Offer:\t\t" + o.getId());
System.out.println("Customer:\t" + o.getCustomerId());
System.out.println("Amount:\t\t$" +
o.getAmount().setScale(2, RoundingMode.HALF_UP));
System.out.println("Status:\t\t" + o.getStatus());
System.out.println();
}
}
// Get car id from user
private Integer getCarIdInput() {
Integer id = 0;
while (true) {
System.out.println("Enter vehicle ID number:");
System.out.print(">>> ");
try {
id = sc.nextInt();
if (cs.getCar(id) == null || cs.getCar(id).getOwnerId() != 0) {
throw new Exception();
}
sc.nextLine();
break;
} catch (InputMismatchException e) {
System.out.println("Invalid input.");
sc.nextLine();
} catch (Exception e) {
System.out.println("Car " + id + " does not exist.");
}
}
return id;
}
}
| [
"codyj@protonmail.com"
] | codyj@protonmail.com |
81a52379b48558b534c95adb387c1685b63693cd | f484aed72c1c2f6de90ce322ad898bf16227fb08 | /mesh-worker-service/src/test/java/io/functionmesh/compute/rest/api/SourcesImpTest.java | 1090e1a13196c90c7db04b0950dd3c16f6f8dc7f | [
"Apache-2.0"
] | permissive | geekcheng/function-mesh | f11d6942e6eece7079eed7264eac5d39702859c0 | 0c3941aa9d7f8f147b2e54f0dd09a3647f34e5bf | refs/heads/master | 2023-05-03T16:19:13.564527 | 2021-05-24T12:08:39 | 2021-05-24T12:08:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 49,704 | 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 io.functionmesh.compute.rest.api;
import com.google.common.collect.Maps;
import io.functionmesh.compute.sources.models.V1alpha1SourceSpecPod;
import io.functionmesh.compute.util.KubernetesUtils;
import io.functionmesh.compute.MeshWorkerService;
import io.functionmesh.compute.sources.models.V1alpha1Source;
import io.functionmesh.compute.util.SourcesUtil;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.JSON;
import io.kubernetes.client.openapi.apis.CustomObjectsApi;
import okhttp3.Call;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.http.RealResponseBody;
import org.apache.commons.io.FileUtils;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.admin.Tenants;
import org.apache.pulsar.common.functions.ProducerConfig;
import org.apache.pulsar.common.functions.Resources;
import org.apache.pulsar.common.io.SourceConfig;
import org.apache.pulsar.common.nar.NarClassLoader;
import org.apache.pulsar.common.policies.data.SourceStatus;
import org.apache.pulsar.functions.utils.FunctionCommon;
import org.apache.pulsar.functions.utils.io.ConnectorUtils;
import org.apache.pulsar.functions.worker.WorkerConfig;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import static org.powermock.api.mockito.PowerMockito.spy;
@RunWith(PowerMockRunner.class)
@PrepareForTest({
Response.class,
RealResponseBody.class,
FunctionCommon.class,
ConnectorUtils.class,
FileUtils.class
})
@PowerMockIgnore({"javax.management.*"})
public class SourcesImpTest {
@Test
public void testRegisterSource()
throws ApiException, IOException, ClassNotFoundException, URISyntaxException, PulsarAdminException {
String testBody =
"{\n"
+ " \"apiVersion\": \"compute.functionmesh.io/v1alpha1\",\n"
+ " \"kind\": \"Source\",\n"
+ " \"metadata\": {\n"
+ " \"annotations\": {\n"
+ " \"kubectl.kubernetes.io/last-applied-configuration\": \"{\\\"apiVersion\\\":\\\"compute.functionmesh.io/v1alpha1\\\",\\\"kind\\\":\\\"Source\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"source-sample\\\",\\\"namespace\\\":\\\"default\\\"},\\\"spec\\\":{\\\"className\\\":\\\"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\\\",\\\"clusterName\\\":\\\"test-pulsar\\\",\\\"java\\\":{\\\"jar\\\":\\\"connectors/pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\\\",\\\"jarLocation\\\":\\\"\\\"},\\\"maxReplicas\\\":1,\\\"output\\\":{\\\"producerConf\\\":{\\\"maxPendingMessages\\\":1000,\\\"maxPendingMessagesAcrossPartitions\\\":50000,\\\"useThreadLocalProducers\\\":true},\\\"topic\\\":\\\"persistent://public/default/destination\\\"},\\\"pulsar\\\":{\\\"pulsarConfig\\\":\\\"test-source\\\"},\\\"replicas\\\":1,\\\"resources\\\":{\\\"limits\\\":{\\\"cpu\\\":\\\"0.2\\\",\\\"memory\\\":\\\"1.1G\\\"},\\\"requests\\\":{\\\"cpu\\\":\\\"0.1\\\",\\\"memory\\\":\\\"1G\\\"}},\\\"sinkType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\",\\\"sourceConfig\\\":{\\\"database.whitelist\\\":\\\"inventory\\\",\\\"mongodb.hosts\\\":\\\"rs0/mongo-dbz-0.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-1.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-2.mongo.default.svc.cluster.local:27017\\\",\\\"mongodb.name\\\":\\\"dbserver1\\\",\\\"mongodb.password\\\":\\\"dbz\\\",\\\"mongodb.task.id\\\":\\\"1\\\",\\\"mongodb.user\\\":\\\"debezium\\\",\\\"pulsar.service.url\\\":\\\"pulsar://test-pulsar-broker.default.svc.cluster.local:6650\\\"},\\\"sourceType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\"}}\\n\"\n"
+ " },\n"
+ " \"creationTimestamp\": \"2020-11-27T07:07:57Z\",\n"
+ " \"generation\": 1,\n"
+ " \"name\": \"source-sample\",\n"
+ " \"namespace\": \"default\",\n"
+ " \"resourceVersion\": \"881034\",\n"
+ " \"selfLink\": \"/apis/compute.functionmesh.io/v1alpha1/namespaces/default/sources/source-sample\",\n"
+ " \"uid\": \"8aed505e-38e4-4a8b-93f6-6f753dbf7ebc\"\n"
+ " },\n"
+ " \"spec\": {\n"
+ " \"className\": \"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\",\n"
+ " \"clusterName\": \"test-pulsar\",\n"
+ " \"java\": {\n"
+ " \"jar\": \"pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\",\n"
+ " \"jarLocation\": \"public/default/source-sample\"\n"
+ " },\n"
+ " \"maxReplicas\": 1,\n"
+ " \"output\": {\n"
+ " \"producerConf\": {\n"
+ " \"maxPendingMessages\": 1000,\n"
+ " \"maxPendingMessagesAcrossPartitions\": 50000,\n"
+ " \"useThreadLocalProducers\": true\n"
+ " },\n"
+ " \"topic\": \"persistent://public/default/destination\"\n"
+ " },\n"
+ " \"pulsar\": {\n"
+ " \"pulsarConfig\": \"test-source\"\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"resources\": {\n"
+ " \"limits\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " },\n"
+ " \"requests\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " }\n"
+ " },\n"
+ " \"sinkType\": \"org.apache.pulsar.common.schema.KeyValue\",\n"
+ " \"sourceConfig\": {\n"
+ " \"name\": \"test-sourceConfig\""
+ " },\n"
+ " \"sourceType\": \"org.apache.pulsar.common.schema.KeyValue\"\n"
+ " },\n"
+ " \"status\": {\n"
+ " \"conditions\": {\n"
+ " \"HorizontalPodAutoscaler\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"HPAReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"Service\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"ServiceReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"StatefulSet\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"StatefulSetReady\",\n"
+ " \"status\": \"True\"\n"
+ " }\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"selector\": \"component=source,name=source-sample,namespace=default\"\n"
+ " }\n"
+ "}";
MeshWorkerService meshWorkerService =
PowerMockito.mock(MeshWorkerService.class);
Supplier<MeshWorkerService> meshWorkerServiceSupplier =
() -> meshWorkerService;
CustomObjectsApi customObjectsApi = PowerMockito.mock(CustomObjectsApi.class);
PowerMockito.when(meshWorkerService.getCustomObjectsApi())
.thenReturn(customObjectsApi);
WorkerConfig workerConfig = PowerMockito.mock(WorkerConfig.class);
PowerMockito.when(meshWorkerService.getWorkerConfig()).thenReturn(workerConfig);
PowerMockito.when(workerConfig.isAuthorizationEnabled()).thenReturn(false);
PowerMockito.when(workerConfig.isAuthenticationEnabled()).thenReturn(false);
PulsarAdmin pulsarAdmin = PowerMockito.mock(PulsarAdmin.class);
PowerMockito.when(meshWorkerService.getBrokerAdmin()).thenReturn(pulsarAdmin);
Tenants tenants = PowerMockito.mock(Tenants.class);
PowerMockito.when(pulsarAdmin.tenants()).thenReturn(tenants);
Call call = PowerMockito.mock(Call.class);
Response response = PowerMockito.mock(Response.class);
ResponseBody responseBody = PowerMockito.mock(RealResponseBody.class);
ApiClient apiClient = PowerMockito.mock(ApiClient.class);
String group = "compute.functionmesh.io";
String plural = "sources";
String version = "v1alpha1";
String kind = "Source";
String tenant = "public";
String namespace = "default";
String componentName = "source-mongodb-sample";
String className = "org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource";
String topicName = "persistent://public/default/destination";
String archive = "connectors/pulsar-io-debezium-mongodb-2.7.0.nar";
int parallelism = 1;
Double cpu = 0.1;
Long ram = 1L;
String clusterName = "test-pulsar";
String customRuntimeOptions = "{\"clusterName\": \"" + clusterName + "\"}";
Map<String, Object> configs = new HashMap<>();
String configsName = "test-sourceConfig";
configs.put("name", configsName);
File narFile = PowerMockito.mock(File.class);
PowerMockito.when(narFile.getPath()).thenReturn("");
FileInputStream uploadedInputStream = PowerMockito.mock(FileInputStream.class);
NarClassLoader narClassLoader = PowerMockito.mock(NarClassLoader.class);
PowerMockito.when(narClassLoader.loadClass(className)).thenReturn(null);
PowerMockito.mockStatic(FunctionCommon.class);
PowerMockito.mockStatic(ConnectorUtils.class);
PowerMockito.mockStatic(FileUtils.class);
PowerMockito.when(FunctionCommon.extractNarClassLoader(narFile, null))
.thenReturn(narClassLoader);
PowerMockito.when(FunctionCommon.createPkgTempFile()).thenReturn(narFile);
PowerMockito.when(ConnectorUtils.getIOSourceClass(narClassLoader)).thenReturn(className);
PowerMockito.<Class<?>>when(FunctionCommon.getSourceType(null)).thenReturn(getClass());
SourceConfig sourceConfig = new SourceConfig();
sourceConfig.setTenant(tenant);
sourceConfig.setNamespace(namespace);
sourceConfig.setName(componentName);
sourceConfig.setTopicName(topicName);
sourceConfig.setArchive(archive);
sourceConfig.setParallelism(parallelism);
sourceConfig.setConfigs(configs);
Resources resources = new Resources();
resources.setRam(ram);
resources.setCpu(cpu);
sourceConfig.setResources(resources);
sourceConfig.setCustomRuntimeOptions(customRuntimeOptions);
PowerMockito.when(tenants.getTenantInfo(tenant)).thenReturn(null);
V1alpha1Source v1alpha1Source =
SourcesUtil.createV1alpha1SourceFromSourceConfig(
kind,
group,
version,
componentName,
null,
uploadedInputStream,
sourceConfig,
null);
Map<String, String> customLabels = Maps.newHashMap();
customLabels.put("pulsar-cluster", clusterName);
customLabels.put("pulsar-tenant", tenant);
customLabels.put("pulsar-namespace", namespace);
customLabels.put("pulsar-component", componentName);
V1alpha1SourceSpecPod pod = new V1alpha1SourceSpecPod();
pod.setLabels(customLabels);
v1alpha1Source.getSpec().pod(pod);
PowerMockito.when(
meshWorkerService
.getCustomObjectsApi()
.createNamespacedCustomObjectCall(
group,
version,
KubernetesUtils.getNamespace(),
plural,
v1alpha1Source,
null,
null,
null,
null))
.thenReturn(call);
PowerMockito.when(call.execute()).thenReturn(response);
PowerMockito.when(response.isSuccessful()).thenReturn(true);
PowerMockito.when(response.body()).thenReturn(responseBody);
PowerMockito.when(responseBody.string()).thenReturn(testBody);
PowerMockito.when(meshWorkerService.getApiClient()).thenReturn(apiClient);
JSON json = new JSON();
PowerMockito.when(apiClient.getJSON()).thenReturn(json);
SourcesImpl sources = spy(new SourcesImpl(meshWorkerServiceSupplier));
try {
sources.registerSource(
tenant,
namespace,
componentName,
uploadedInputStream,
null,
null,
sourceConfig,
null,
null);
} catch (Exception exception) {
Assert.fail("No exception, but got error message: " + exception.getMessage());
}
}
@Test
public void testUpdateSource()
throws ApiException, IOException, ClassNotFoundException {
String getBody =
"{\n"
+ " \"apiVersion\": \"compute.functionmesh.io/v1alpha1\",\n"
+ " \"kind\": \"Source\",\n"
+ " \"metadata\": {\n"
+ " \"resourceVersion\": \"881033\""
+ " }\n"
+ "}";
String replaceBody =
"{\n"
+ " \"apiVersion\": \"compute.functionmesh.io/v1alpha1\",\n"
+ " \"kind\": \"Source\",\n"
+ " \"metadata\": {\n"
+ " \"annotations\": {\n"
+ " \"kubectl.kubernetes.io/last-applied-configuration\": \"{\\\"apiVersion\\\":\\\"compute.functionmesh.io/v1alpha1\\\",\\\"kind\\\":\\\"Source\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"source-sample\\\",\\\"namespace\\\":\\\"default\\\"},\\\"spec\\\":{\\\"className\\\":\\\"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\\\",\\\"clusterName\\\":\\\"test-pulsar\\\",\\\"java\\\":{\\\"jar\\\":\\\"connectors/pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\\\",\\\"jarLocation\\\":\\\"\\\"},\\\"maxReplicas\\\":1,\\\"output\\\":{\\\"producerConf\\\":{\\\"maxPendingMessages\\\":1000,\\\"maxPendingMessagesAcrossPartitions\\\":50000,\\\"useThreadLocalProducers\\\":true},\\\"topic\\\":\\\"persistent://public/default/destination\\\"},\\\"pulsar\\\":{\\\"pulsarConfig\\\":\\\"test-source\\\"},\\\"replicas\\\":1,\\\"resources\\\":{\\\"limits\\\":{\\\"cpu\\\":\\\"0.2\\\",\\\"memory\\\":\\\"1.1G\\\"},\\\"requests\\\":{\\\"cpu\\\":\\\"0.1\\\",\\\"memory\\\":\\\"1G\\\"}},\\\"sinkType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\",\\\"sourceConfig\\\":{\\\"database.whitelist\\\":\\\"inventory\\\",\\\"mongodb.hosts\\\":\\\"rs0/mongo-dbz-0.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-1.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-2.mongo.default.svc.cluster.local:27017\\\",\\\"mongodb.name\\\":\\\"dbserver1\\\",\\\"mongodb.password\\\":\\\"dbz\\\",\\\"mongodb.task.id\\\":\\\"1\\\",\\\"mongodb.user\\\":\\\"debezium\\\",\\\"pulsar.service.url\\\":\\\"pulsar://test-pulsar-broker.default.svc.cluster.local:6650\\\"},\\\"sourceType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\"}}\\n\"\n"
+ " },\n"
+ " \"creationTimestamp\": \"2020-11-27T07:07:57Z\",\n"
+ " \"generation\": 1,\n"
+ " \"name\": \"source-sample\",\n"
+ " \"namespace\": \"default\",\n"
+ " \"resourceVersion\": \"881034\",\n"
+ " \"selfLink\": \"/apis/compute.functionmesh.io/v1alpha1/namespaces/default/sources/source-sample\",\n"
+ " \"uid\": \"8aed505e-38e4-4a8b-93f6-6f753dbf7ebc\"\n"
+ " },\n"
+ " \"spec\": {\n"
+ " \"className\": \"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\",\n"
+ " \"clusterName\": \"test-pulsar\",\n"
+ " \"java\": {\n"
+ " \"jar\": \"pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\",\n"
+ " \"jarLocation\": \"public/default/source-sample\"\n"
+ " },\n"
+ " \"maxReplicas\": 1,\n"
+ " \"output\": {\n"
+ " \"producerConf\": {\n"
+ " \"maxPendingMessages\": 1000,\n"
+ " \"maxPendingMessagesAcrossPartitions\": 50000,\n"
+ " \"useThreadLocalProducers\": true\n"
+ " },\n"
+ " \"topic\": \"persistent://public/default/destination\"\n"
+ " },\n"
+ " \"pulsar\": {\n"
+ " \"pulsarConfig\": \"test-source\"\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"resources\": {\n"
+ " \"limits\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " },\n"
+ " \"requests\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " }\n"
+ " },\n"
+ " \"sinkType\": \"org.apache.pulsar.common.schema.KeyValue\",\n"
+ " \"sourceConfig\": {\n"
+ " \"name\": \"test-sourceConfig\""
+ " },\n"
+ " \"sourceType\": \"org.apache.pulsar.common.schema.KeyValue\"\n"
+ " },\n"
+ " \"status\": {\n"
+ " \"conditions\": {\n"
+ " \"HorizontalPodAutoscaler\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"HPAReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"Service\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"ServiceReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"StatefulSet\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"StatefulSetReady\",\n"
+ " \"status\": \"True\"\n"
+ " }\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"selector\": \"component=source,name=source-sample,namespace=default\"\n"
+ " }\n"
+ "}";
String group = "compute.functionmesh.io";
String plural = "sources";
String version = "v1alpha1";
String kind = "Source";
String tenant = "public";
String namespace = "default";
String componentName = "source-mongodb-sample";
String className = "org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource";
String topicName = "persistent://public/default/destination";
String archive = "connectors/pulsar-io-debezium-mongodb-2.7.0.nar";
int parallelism = 1;
Double cpu = 0.1;
Long ram = 1L;
String clusterName = "test-pulsar";
String customRuntimeOptions = "{\"clusterName\": \"" + clusterName + "\"}";
Map<String, Object> configs = new HashMap<>();
String configsName = "test-sourceConfig";
configs.put("name", configsName);
File narFile = PowerMockito.mock(File.class);
PowerMockito.when(narFile.getPath()).thenReturn("");
FileInputStream uploadedInputStream = PowerMockito.mock(FileInputStream.class);
NarClassLoader narClassLoader = PowerMockito.mock(NarClassLoader.class);
PowerMockito.when(narClassLoader.loadClass(className)).thenReturn(null);
PowerMockito.mockStatic(FunctionCommon.class);
PowerMockito.mockStatic(ConnectorUtils.class);
PowerMockito.mockStatic(FileUtils.class);
PowerMockito.when(FunctionCommon.extractNarClassLoader(narFile, null))
.thenReturn(narClassLoader);
PowerMockito.when(FunctionCommon.createPkgTempFile()).thenReturn(narFile);
PowerMockito.when(ConnectorUtils.getIOSourceClass(narClassLoader)).thenReturn(className);
PowerMockito.<Class<?>>when(FunctionCommon.getSourceType(null)).thenReturn(getClass());
SourceConfig sourceConfig = new SourceConfig();
sourceConfig.setTenant(tenant);
sourceConfig.setNamespace(namespace);
sourceConfig.setName(componentName);
sourceConfig.setTopicName(topicName);
sourceConfig.setArchive(archive);
sourceConfig.setParallelism(parallelism);
sourceConfig.setConfigs(configs);
Resources resources = new Resources();
resources.setRam(ram);
resources.setCpu(cpu);
sourceConfig.setResources(resources);
sourceConfig.setCustomRuntimeOptions(customRuntimeOptions);
MeshWorkerService meshWorkerService =
PowerMockito.mock(MeshWorkerService.class);
Supplier<MeshWorkerService> meshWorkerServiceSupplier =
() -> meshWorkerService;
CustomObjectsApi customObjectsApi = PowerMockito.mock(CustomObjectsApi.class);
PowerMockito.when(meshWorkerService.getCustomObjectsApi())
.thenReturn(customObjectsApi);
WorkerConfig workerConfig = PowerMockito.mock(WorkerConfig.class);
PowerMockito.when(meshWorkerService.getWorkerConfig()).thenReturn(workerConfig);
PowerMockito.when(workerConfig.isAuthorizationEnabled()).thenReturn(false);
PowerMockito.when(workerConfig.isAuthenticationEnabled()).thenReturn(false);
Call getCall = PowerMockito.mock(Call.class);
Response getResponse = PowerMockito.mock(Response.class);
ResponseBody getResponseBody = PowerMockito.mock(RealResponseBody.class);
PowerMockito.when(getCall.execute()).thenReturn(getResponse);
PowerMockito.when(getResponse.isSuccessful()).thenReturn(true);
PowerMockito.when(getResponse.body()).thenReturn(getResponseBody);
PowerMockito.when(getResponseBody.string()).thenReturn(getBody);
Call replaceCall = PowerMockito.mock(Call.class);
Response replaceResponse = PowerMockito.mock(Response.class);
ResponseBody replaceResponseBody = PowerMockito.mock(RealResponseBody.class);
PowerMockito.when(replaceCall.execute()).thenReturn(replaceResponse);
PowerMockito.when(replaceResponse.isSuccessful()).thenReturn(true);
PowerMockito.when(replaceResponse.body()).thenReturn(getResponseBody);
PowerMockito.when(replaceResponseBody.string()).thenReturn(replaceBody);
ApiClient apiClient = PowerMockito.mock(ApiClient.class);
PowerMockito.when(meshWorkerService.getApiClient()).thenReturn(apiClient);
JSON json = new JSON();
PowerMockito.when(apiClient.getJSON()).thenReturn(json);
PowerMockito.when(
meshWorkerService
.getCustomObjectsApi()
.getNamespacedCustomObjectCall(
group, version, namespace, plural, componentName, null))
.thenReturn(getCall);
V1alpha1Source v1alpha1Source =
SourcesUtil.createV1alpha1SourceFromSourceConfig(
kind,
group,
version,
componentName,
null,
uploadedInputStream,
sourceConfig, null);
v1alpha1Source.getMetadata().setResourceVersion("881033");
PowerMockito.when(
meshWorkerService
.getCustomObjectsApi()
.replaceNamespacedCustomObjectCall(
group,
version,
KubernetesUtils.getNamespace(),
plural,
componentName,
v1alpha1Source,
null,
null,
null))
.thenReturn(getCall);
SourcesImpl sources = spy(new SourcesImpl(meshWorkerServiceSupplier));
try {
sources.updateSource(
tenant,
namespace,
componentName,
uploadedInputStream,
null,
null,
sourceConfig,
null,
null,
null);
} catch (Exception exception) {
Assert.fail("Expected no exception to be thrown but got " + exception.getMessage());
}
}
@Test
public void testGetSourceStatus()
throws ClassNotFoundException, IOException, URISyntaxException, ApiException {
String testBody =
"{\n"
+ " \"apiVersion\": \"compute.functionmesh.io/v1alpha1\",\n"
+ " \"kind\": \"Source\",\n"
+ " \"metadata\": {\n"
+ " \"annotations\": {\n"
+ " \"kubectl.kubernetes.io/last-applied-configuration\": \"{\\\"apiVersion\\\":\\\"compute.functionmesh.io/v1alpha1\\\",\\\"kind\\\":\\\"Source\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"source-sample\\\",\\\"namespace\\\":\\\"default\\\"},\\\"spec\\\":{\\\"className\\\":\\\"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\\\",\\\"clusterName\\\":\\\"test-pulsar\\\",\\\"java\\\":{\\\"jar\\\":\\\"connectors/pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\\\",\\\"jarLocation\\\":\\\"\\\"},\\\"maxReplicas\\\":1,\\\"output\\\":{\\\"producerConf\\\":{\\\"maxPendingMessages\\\":1000,\\\"maxPendingMessagesAcrossPartitions\\\":50000,\\\"useThreadLocalProducers\\\":true},\\\"topic\\\":\\\"persistent://public/default/destination\\\"},\\\"pulsar\\\":{\\\"pulsarConfig\\\":\\\"test-source\\\"},\\\"replicas\\\":1,\\\"resources\\\":{\\\"limits\\\":{\\\"cpu\\\":\\\"0.2\\\",\\\"memory\\\":\\\"1.1G\\\"},\\\"requests\\\":{\\\"cpu\\\":\\\"0.1\\\",\\\"memory\\\":\\\"1G\\\"}},\\\"sinkType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\",\\\"sourceConfig\\\":{\\\"database.whitelist\\\":\\\"inventory\\\",\\\"mongodb.hosts\\\":\\\"rs0/mongo-dbz-0.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-1.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-2.mongo.default.svc.cluster.local:27017\\\",\\\"mongodb.name\\\":\\\"dbserver1\\\",\\\"mongodb.password\\\":\\\"dbz\\\",\\\"mongodb.task.id\\\":\\\"1\\\",\\\"mongodb.user\\\":\\\"debezium\\\",\\\"pulsar.service.url\\\":\\\"pulsar://test-pulsar-broker.default.svc.cluster.local:6650\\\"},\\\"sourceType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\"}}\\n\"\n"
+ " },\n"
+ " \"creationTimestamp\": \"2020-11-27T07:07:57Z\",\n"
+ " \"generation\": 1,\n"
+ " \"name\": \"source-mongodb-sample\",\n"
+ " \"namespace\": \"default\",\n"
+ " \"resourceVersion\": \"881034\",\n"
+ " \"selfLink\": \"/apis/compute.functionmesh.io/v1alpha1/namespaces/default/sources/source-sample\",\n"
+ " \"uid\": \"8aed505e-38e4-4a8b-93f6-6f753dbf7ebc\"\n"
+ " },\n"
+ " \"spec\": {\n"
+ " \"className\": \"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\",\n"
+ " \"clusterName\": \"test-pulsar\",\n"
+ " \"java\": {\n"
+ " \"jar\": \"pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\",\n"
+ " \"jarLocation\": \"public/default/source-sample\"\n"
+ " },\n"
+ " \"maxReplicas\": 1,\n"
+ " \"output\": {\n"
+ " \"producerConf\": {\n"
+ " \"maxPendingMessages\": 1000,\n"
+ " \"maxPendingMessagesAcrossPartitions\": 50000,\n"
+ " \"useThreadLocalProducers\": true\n"
+ " },\n"
+ " \"topic\": \"persistent://public/default/destination\"\n"
+ " },\n"
+ " \"pulsar\": {\n"
+ " \"pulsarConfig\": \"test-source\"\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"resources\": {\n"
+ " \"limits\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " },\n"
+ " \"requests\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " }\n"
+ " },\n"
+ " \"sinkType\": \"org.apache.pulsar.common.schema.KeyValue\",\n"
+ " \"sourceConfig\": {\n"
+ " \"name\": \"test-sourceConfig\""
+ " },\n"
+ " \"sourceType\": \"org.apache.pulsar.common.schema.KeyValue\"\n"
+ " },\n"
+ " \"status\": {\n"
+ " \"conditions\": {\n"
+ " \"HorizontalPodAutoscaler\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"HPAReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"Service\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"ServiceReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"StatefulSet\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"StatefulSetReady\",\n"
+ " \"status\": \"True\"\n"
+ " }\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"selector\": \"component=source,name=source-sample,namespace=default\"\n"
+ " }\n"
+ "}";
MeshWorkerService meshWorkerService =
PowerMockito.mock(MeshWorkerService.class);
Supplier<MeshWorkerService> meshWorkerServiceSupplier =
() -> meshWorkerService;
CustomObjectsApi customObjectsApi = PowerMockito.mock(CustomObjectsApi.class);
PowerMockito.when(meshWorkerService.getCustomObjectsApi())
.thenReturn(customObjectsApi);
WorkerConfig workerConfig = PowerMockito.mock(WorkerConfig.class);
PowerMockito.when(meshWorkerService.getWorkerConfig()).thenReturn(workerConfig);
PowerMockito.when(workerConfig.isAuthorizationEnabled()).thenReturn(false);
PowerMockito.when(workerConfig.isAuthenticationEnabled()).thenReturn(false);
Call call = PowerMockito.mock(Call.class);
Response response = PowerMockito.mock(Response.class);
ResponseBody responseBody = PowerMockito.mock(RealResponseBody.class);
ApiClient apiClient = PowerMockito.mock(ApiClient.class);
String group = "compute.functionmesh.io";
String plural = "sources";
String version = "v1alpha1";
String tenant = "public";
String namespace = "default";
String componentName = "source-mongodb-sample";
PowerMockito.when(
meshWorkerService
.getCustomObjectsApi()
.getNamespacedCustomObjectCall(
group, version, namespace, plural, componentName, null))
.thenReturn(call);
PowerMockito.when(call.execute()).thenReturn(response);
PowerMockito.when(response.isSuccessful()).thenReturn(true);
PowerMockito.when(response.body()).thenReturn(responseBody);
PowerMockito.when(responseBody.string()).thenReturn(testBody);
PowerMockito.when(meshWorkerService.getApiClient()).thenReturn(apiClient);
JSON json = new JSON();
PowerMockito.when(apiClient.getJSON()).thenReturn(json);
SourcesImpl sources = spy(new SourcesImpl(meshWorkerServiceSupplier));
SourceStatus sourceStatus =
sources.getSourceStatus(tenant, namespace, componentName, null, null, null);
SourceStatus expectedSourceStatus = new SourceStatus();
SourceStatus.SourceInstanceStatus expectedSourceInstanceStatus =
new SourceStatus.SourceInstanceStatus();
SourceStatus.SourceInstanceStatus.SourceInstanceStatusData
expectedSourceInstanceStatusData =
new SourceStatus.SourceInstanceStatus.SourceInstanceStatusData();
expectedSourceInstanceStatusData.setRunning(true);
expectedSourceInstanceStatusData.setWorkerId("test-pulsar");
expectedSourceInstanceStatus.setStatus(expectedSourceInstanceStatusData);
expectedSourceStatus.addInstance(expectedSourceInstanceStatus);
expectedSourceStatus.setNumInstances(expectedSourceStatus.getInstances().size());
Assert.assertEquals(expectedSourceStatus, sourceStatus);
}
@Test
public void testGetSourceInfo()
throws ApiException, IOException, ClassNotFoundException, URISyntaxException {
String testBody =
"{\n"
+ " \"apiVersion\": \"compute.functionmesh.io/v1alpha1\",\n"
+ " \"kind\": \"Source\",\n"
+ " \"metadata\": {\n"
+ " \"annotations\": {\n"
+ " \"kubectl.kubernetes.io/last-applied-configuration\": \"{\\\"apiVersion\\\":\\\"compute.functionmesh.io/v1alpha1\\\",\\\"kind\\\":\\\"Source\\\",\\\"metadata\\\":{\\\"annotations\\\":{},\\\"name\\\":\\\"source-sample\\\",\\\"namespace\\\":\\\"default\\\"},\\\"spec\\\":{\\\"className\\\":\\\"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\\\",\\\"clusterName\\\":\\\"test-pulsar\\\",\\\"java\\\":{\\\"jar\\\":\\\"connectors/pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\\\",\\\"jarLocation\\\":\\\"\\\"},\\\"maxReplicas\\\":1,\\\"output\\\":{\\\"producerConf\\\":{\\\"maxPendingMessages\\\":1000,\\\"maxPendingMessagesAcrossPartitions\\\":50000,\\\"useThreadLocalProducers\\\":true},\\\"topic\\\":\\\"persistent://public/default/destination\\\"},\\\"pulsar\\\":{\\\"pulsarConfig\\\":\\\"test-source\\\"},\\\"replicas\\\":1,\\\"resources\\\":{\\\"limits\\\":{\\\"cpu\\\":\\\"0.2\\\",\\\"memory\\\":\\\"1.1G\\\"},\\\"requests\\\":{\\\"cpu\\\":\\\"0.1\\\",\\\"memory\\\":\\\"1G\\\"}},\\\"sinkType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\",\\\"sourceConfig\\\":{\\\"database.whitelist\\\":\\\"inventory\\\",\\\"mongodb.hosts\\\":\\\"rs0/mongo-dbz-0.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-1.mongo.default.svc.cluster.local:27017,rs0/mongo-dbz-2.mongo.default.svc.cluster.local:27017\\\",\\\"mongodb.name\\\":\\\"dbserver1\\\",\\\"mongodb.password\\\":\\\"dbz\\\",\\\"mongodb.task.id\\\":\\\"1\\\",\\\"mongodb.user\\\":\\\"debezium\\\",\\\"pulsar.service.url\\\":\\\"pulsar://test-pulsar-broker.default.svc.cluster.local:6650\\\"},\\\"sourceType\\\":\\\"org.apache.pulsar.common.schema.KeyValue\\\"}}\\n\"\n"
+ " },\n"
+ " \"creationTimestamp\": \"2020-11-27T07:07:57Z\",\n"
+ " \"generation\": 1,\n"
+ " \"name\": \"source-sample\",\n"
+ " \"namespace\": \"default\",\n"
+ " \"resourceVersion\": \"881034\",\n"
+ " \"selfLink\": \"/apis/compute.functionmesh.io/v1alpha1/namespaces/default/sources/source-sample\",\n"
+ " \"uid\": \"8aed505e-38e4-4a8b-93f6-6f753dbf7ebc\"\n"
+ " },\n"
+ " \"spec\": {\n"
+ " \"className\": \"org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource\",\n"
+ " \"clusterName\": \"test-pulsar\",\n"
+ " \"java\": {\n"
+ " \"jar\": \"pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar\",\n"
+ " \"jarLocation\": \"public/default/source-sample\"\n"
+ " },\n"
+ " \"maxReplicas\": 1,\n"
+ " \"output\": {\n"
+ " \"producerConf\": {\n"
+ " \"maxPendingMessages\": 1000,\n"
+ " \"maxPendingMessagesAcrossPartitions\": 50000,\n"
+ " \"useThreadLocalProducers\": true\n"
+ " },\n"
+ " \"topic\": \"persistent://public/default/destination\"\n"
+ " },\n"
+ " \"pulsar\": {\n"
+ " \"pulsarConfig\": \"test-source\"\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"resources\": {\n"
+ " \"limits\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " },\n"
+ " \"requests\": {\n"
+ " \"cpu\": \"0.1\",\n"
+ " \"memory\": \"1\"\n"
+ " }\n"
+ " },\n"
+ " \"sinkType\": \"org.apache.pulsar.common.schema.KeyValue\",\n"
+ " \"sourceConfig\": {\n"
+ " \"name\": \"test-sourceConfig\""
+ " },\n"
+ " \"sourceType\": \"org.apache.pulsar.common.schema.KeyValue\"\n"
+ " },\n"
+ " \"status\": {\n"
+ " \"conditions\": {\n"
+ " \"HorizontalPodAutoscaler\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"HPAReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"Service\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"ServiceReady\",\n"
+ " \"status\": \"True\"\n"
+ " },\n"
+ " \"StatefulSet\": {\n"
+ " \"action\": \"NoAction\",\n"
+ " \"condition\": \"StatefulSetReady\",\n"
+ " \"status\": \"True\"\n"
+ " }\n"
+ " },\n"
+ " \"replicas\": 1,\n"
+ " \"selector\": \"component=source,name=source-sample,namespace=default\"\n"
+ " }\n"
+ "}";
MeshWorkerService meshWorkerService =
PowerMockito.mock(MeshWorkerService.class);
Supplier<MeshWorkerService> meshWorkerServiceSupplier =
() -> meshWorkerService;
CustomObjectsApi customObjectsApi = PowerMockito.mock(CustomObjectsApi.class);
PowerMockito.when(meshWorkerService.getCustomObjectsApi())
.thenReturn(customObjectsApi);
WorkerConfig workerConfig = PowerMockito.mock(WorkerConfig.class);
PowerMockito.when(meshWorkerService.getWorkerConfig()).thenReturn(workerConfig);
PowerMockito.when(workerConfig.isAuthorizationEnabled()).thenReturn(false);
PowerMockito.when(workerConfig.isAuthenticationEnabled()).thenReturn(false);
Call call = PowerMockito.mock(Call.class);
Response response = PowerMockito.mock(Response.class);
ResponseBody responseBody = PowerMockito.mock(RealResponseBody.class);
ApiClient apiClient = PowerMockito.mock(ApiClient.class);
String group = "compute.functionmesh.io";
String plural = "sources";
String version = "v1alpha1";
String tenant = "public";
String namespace = "default";
String componentName = "source-mongodb-sample";
PowerMockito.when(
meshWorkerService
.getCustomObjectsApi()
.getNamespacedCustomObjectCall(
group, version, namespace, plural, componentName, null))
.thenReturn(call);
PowerMockito.when(call.execute()).thenReturn(response);
PowerMockito.when(response.isSuccessful()).thenReturn(true);
PowerMockito.when(response.body()).thenReturn(responseBody);
PowerMockito.when(responseBody.string()).thenReturn(testBody);
PowerMockito.when(meshWorkerService.getApiClient()).thenReturn(apiClient);
JSON json = new JSON();
PowerMockito.when(apiClient.getJSON()).thenReturn(json);
String className = "org.apache.pulsar.io.debezium.mongodb.DebeziumMongoDbSource";
String topicName = "persistent://public/default/destination";
String archive = "pulsar-io-debezium-mongodb-2.7.0-rc-pm-3.nar";
int parallelism = 1;
Double cpu = 0.1;
Long ram = 1L;
String clusterName = "test-pulsar";
String customRuntimeOptions = "{\"clusterName\":\"" + clusterName + "\"}";
Map<String, Object> configs = new HashMap<>();
String configsName = "test-sourceConfig";
configs.put("name", configsName);
SourceConfig expectedSourceConfig = new SourceConfig();
expectedSourceConfig.setTenant(tenant);
expectedSourceConfig.setNamespace(namespace);
expectedSourceConfig.setName(componentName);
expectedSourceConfig.setClassName(className);
expectedSourceConfig.setTopicName(topicName);
expectedSourceConfig.setArchive(archive);
expectedSourceConfig.setParallelism(parallelism);
expectedSourceConfig.setConfigs(configs);
ProducerConfig producerConfig = new ProducerConfig();
producerConfig.setMaxPendingMessages(1000);
producerConfig.setMaxPendingMessagesAcrossPartitions(50000);
producerConfig.setUseThreadLocalProducers(true);
expectedSourceConfig.setProducerConfig(producerConfig);
Resources resources = new Resources();
resources.setRam(ram);
resources.setCpu(cpu);
expectedSourceConfig.setResources(resources);
expectedSourceConfig.setCustomRuntimeOptions(customRuntimeOptions);
SourcesImpl sources = spy(new SourcesImpl(meshWorkerServiceSupplier));
SourceConfig actualSourceConfig = sources.getSourceInfo(tenant, namespace, componentName);
Assert.assertEquals(expectedSourceConfig.getName(), actualSourceConfig.getName());
Assert.assertEquals(expectedSourceConfig.getNamespace(), actualSourceConfig.getNamespace());
Assert.assertEquals(expectedSourceConfig.getTenant(), actualSourceConfig.getTenant());
Assert.assertEquals(expectedSourceConfig.getConfigs(), actualSourceConfig.getConfigs());
Assert.assertEquals(expectedSourceConfig.getArchive(), actualSourceConfig.getArchive());
Assert.assertEquals(expectedSourceConfig.getResources(), actualSourceConfig.getResources());
Assert.assertEquals(expectedSourceConfig.getClassName(), actualSourceConfig.getClassName());
Assert.assertEquals(expectedSourceConfig.getCustomRuntimeOptions(), actualSourceConfig.getCustomRuntimeOptions());
Assert.assertEquals(expectedSourceConfig.getTopicName(), actualSourceConfig.getTopicName());
Assert.assertEquals(expectedSourceConfig.getParallelism(), actualSourceConfig.getParallelism());
Assert.assertEquals(expectedSourceConfig.getRuntimeFlags(), actualSourceConfig.getRuntimeFlags());
}
}
| [
"noreply@github.com"
] | noreply@github.com |
dac57b841234c3d6b6148e23ab0f691d1661793b | cff04c0039bc6847b3ffb3bc2acc417447ab99ff | /app/src/main/java/com/example/tijoj/userpage/POJO/User.java | cf03ef5dbbad7250b7ed7ab65b92f69629d0fbb6 | [] | no_license | tijojose27/UserPage | 880c270ca2b9fbca20d7ad83b2538273d4ddf38a | 67cedd91206254588b3c11fd467c0e340663cc3b | refs/heads/master | 2020-03-16T06:31:46.301608 | 2018-05-16T04:08:40 | 2018-05-16T04:08:40 | 132,556,925 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,410 | java | package com.example.tijoj.userpage.POJO;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Calendar;
/**
* Created by tijoj on 5/8/2018.
*/
public class User implements Parcelable{
private String email;
private String password;
private String name;
private int zip;
private int gender;
private String dob;
private int genderPref;
private int ageMin;
private int ageMax;
private String race;
private String religion;
private String height;
private Uri profilePicUri;
public User(String email, String password) {
this.email = email;
this.password = password;
}
protected User(Parcel in) {
email = in.readString();
password = in.readString();
name = in.readString();
zip = in.readInt();
gender = in.readInt();
dob = in.readString();
genderPref = in.readInt();
ageMin = in.readInt();
ageMax = in.readInt();
race = in.readString();
religion = in.readString();
height = in.readString();
profilePicUri = in.readParcelable(Uri.class.getClassLoader());
}
public static final Creator<User> CREATOR = new Creator<User>() {
@Override
public User createFromParcel(Parcel in) {
return new User(in);
}
@Override
public User[] newArray(int size) {
return new User[size];
}
};
public String getEmail() {
return email;
}
public String getHeight() {
String mHeight = height.substring(0,1)+"'"+height.substring(1,height.length())+"\"";
return mHeight;
}
public void setHeight(String height) {
this.height = height;
}
public String getPassword() {
return password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getZip() {
return (String.valueOf(zip));
}
public void setZip(int zip) {
this.zip = zip;
}
public String getGender() {
return getGenderFromInt(gender);
}
public void setGender(int gender) {
this.gender = gender;
}
public String getAge(){
String personYear = dob.substring(dob.length() -4);
int mYear = Integer.valueOf(personYear);
int year = Calendar.getInstance().get(Calendar.YEAR);
return String.valueOf(year-mYear);
}
public void setDob(String dob) {
this.dob = dob;
}
public String getGenderPref() {
return getGenderFromInt(genderPref);
}
public void setGenderPref(int genderPref) {
this.genderPref = genderPref;
}
public int getAgeMin() {
return ageMin;
}
public void setAgeMin(int ageMin) {
this.ageMin = ageMin;
}
public int getAgeMax() {
return ageMax;
}
public void setAgeMax(int ageMax) {
this.ageMax = ageMax;
}
public String getRace() {
return race;
}
public void setRace(String race) {
this.race = race;
}
public String getReligion() {
return religion;
}
public void setReligion(String religion) {
this.religion = religion;
}
public Uri getProfilePicUri() {
return profilePicUri;
}
public void setProfilePicUri(Uri profilePicUri) {
this.profilePicUri = profilePicUri;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(email);
parcel.writeString(password);
parcel.writeString(name);
parcel.writeInt(zip);
parcel.writeInt(gender);
parcel.writeString(dob);
parcel.writeInt(genderPref);
parcel.writeInt(ageMin);
parcel.writeInt(ageMax);
parcel.writeString(race);
parcel.writeString(religion);
parcel.writeString(height);
parcel.writeParcelable(profilePicUri, i);
}
public String getGenderFromInt(int i){
switch (i){
case 1:
return "Male";
case 2:
return "Female";
case 3:
return "Other";
default:
return "None";
}
}
}
| [
"tijojose27@yahoo.com"
] | tijojose27@yahoo.com |
9ff6e4a05885b442b799839d8e48dfb96cb0c600 | f045bd8718eecdd3209290f3c94477c9a869f9af | /sources/android/support/v4/view/KeyEventCompat.java | fe1df2200e053250cb6a97e42c3fd7b2578541d2 | [] | no_license | KswCarProject/Launcher3-PX6 | ba6c44c150649ba2f8ea40eb49fde1c2dc6bee5e | 56eab00443667f38622a94975f69011e56d6dc27 | refs/heads/master | 2022-06-18T02:41:27.553573 | 2020-05-13T02:05:40 | 2020-05-13T02:05:40 | 259,748,185 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,583 | java | package android.support.v4.view;
import android.view.KeyEvent;
import android.view.View;
@Deprecated
public final class KeyEventCompat {
@Deprecated
public static int normalizeMetaState(int metaState) {
return KeyEvent.normalizeMetaState(metaState);
}
@Deprecated
public static boolean metaStateHasModifiers(int metaState, int modifiers) {
return KeyEvent.metaStateHasModifiers(metaState, modifiers);
}
@Deprecated
public static boolean metaStateHasNoModifiers(int metaState) {
return KeyEvent.metaStateHasNoModifiers(metaState);
}
@Deprecated
public static boolean hasModifiers(KeyEvent event, int modifiers) {
return event.hasModifiers(modifiers);
}
@Deprecated
public static boolean hasNoModifiers(KeyEvent event) {
return event.hasNoModifiers();
}
@Deprecated
public static void startTracking(KeyEvent event) {
event.startTracking();
}
@Deprecated
public static boolean isTracking(KeyEvent event) {
return event.isTracking();
}
@Deprecated
public static Object getKeyDispatcherState(View view) {
return view.getKeyDispatcherState();
}
@Deprecated
public static boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state, Object target) {
return event.dispatch(receiver, (KeyEvent.DispatcherState) state, target);
}
@Deprecated
public static boolean isCtrlPressed(KeyEvent event) {
return event.isCtrlPressed();
}
private KeyEventCompat() {
}
}
| [
"nicholas@prjkt.io"
] | nicholas@prjkt.io |
8be1210d3de7aa97696ea173447639e19c802066 | 3bf9f9fbdcc10f5705792a82579b41028e5eb46d | /JavaSamples/src/test/com/examples/srini/TellerTestJunit4.java | ce211ed0c98a99a7038d4d6570af1a1cdcfb301b | [] | no_license | srinikandula/MyRepository | eef929783ebd7fded6e2d7ce62f606914aa942ae | 56984bfd94f95f6b1ed1d6d3a4f70e48c66d7488 | refs/heads/master | 2020-04-22T08:06:49.896826 | 2012-10-23T21:36:42 | 2012-10-23T21:36:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,005 | java | package test.com.examples.srini;
import junit.framework.Assert;
import org.junit.Test;
import com.examples.srini.Account;
import com.examples.srini.Teller;
public class TellerTestJunit4 {
@Test
public void withDraw(){
System.out.println("calling testWithDraw");
Account account = new Account();
account.setBalance(1000);
Teller teller = new Teller();
teller.withdraw(account, 1000.0);
Assert.assertEquals(account.getBalance(), 0.0);
}
@Test
public void deposit(){
System.out.println("calling testDeposit");
Account account = new Account();
account.setBalance(1000);
Teller teller = new Teller();
teller.deposit(account, 1000.0);
Assert.assertEquals("The deposit is not working good",account.getBalance(), 20.0);
}
public void testError() throws Exception{
System.out.println("calling testError");
if(true)
throw new Exception();
}
public void noUnitTest(){
System.out.println("calling noUnitTest");
}
}
| [
"srinivas_j2ee@yahoo.com"
] | srinivas_j2ee@yahoo.com |
114db7e8616b6bd858f0cc4538188af8828b2e0e | 9370052ae97a6c1f795bc9bff0e2ab3b32125b9b | /app/src/test/java/myview/dxp/com/qrcodecard/ExampleUnitTest.java | 3b016036d61effa4360968d86e05ff815afd3b15 | [] | no_license | Freshcanbringcool/QRCodeCard | 92983c74bf0103b979750e35978d8144ca797912 | 3fdcc7528be8d4848f6482220210890e86726f77 | refs/heads/master | 2020-04-05T06:10:06.728182 | 2018-11-08T00:42:51 | 2018-11-08T00:42:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 318 | java | package myview.dxp.com.qrcodecard;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"307572384@qq.com"
] | 307572384@qq.com |
700e1d5ffe65575fbc865503aa28a43850be677b | 760e94acedbb4ce55f672bbe8ec6dd7930ed52c4 | /app/src/main/java/com/kyle/mycar/db/Dao/OilDao.java | 9f82f155b4ca7612b78b29343cb66850473bd1a0 | [] | no_license | ZXQ-Kyle/MyCarManager | 1541c6e4deaa5eee2dd93ccd10bfa4f43773c143 | 76250c124b557c96d8b77e422c7dd436bb42cc70 | refs/heads/master | 2020-12-03T02:28:43.952773 | 2017-07-01T06:28:32 | 2017-07-01T06:28:32 | 95,942,418 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,991 | java | package com.kyle.mycar.db.Dao;
import android.content.Context;
import android.util.Log;
import com.j256.ormlite.dao.Dao;
import com.kyle.mycar.db.DbOpenHelper;
import com.kyle.mycar.db.Table.Oil;
import java.sql.SQLException;
import java.util.List;
/**
*
* Created by Zhang on 2017/5/15.
*/
public class OilDao extends DaoUtils{
private static OilDao instance;
private OilDao(Context context,Class clazz) {
super(context,clazz);
}
public static synchronized OilDao getInstance(Context context) {
if (instance == null) {
context = context.getApplicationContext();
synchronized (OilDao.class) {
if (instance == null) {
instance=new OilDao(context, Oil.class);
}
}
}
return instance;
}
/**按时间降序排序后,查询最新一个数据eq(column, value),
* 并且isDelete=false,"isFull"=true
* @param column
* @param value
* @param limitRow
* @return
*/
public List<Oil> queryNewest(String column, Object value, long limitRow) {
try {
return mDao.queryBuilder()
.limit(limitRow)
.orderBy("date",false)
.where()
.eq("isDelete", false).and()
.eq("isFull",true).and()
.eq(column, value)
.query();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
/** < (column, value)
* eq("isDelete", false).and().eq("isFull",true) false表示降序,true表示升序
* @param column 比较列列名
* @param value 比较列数值
* @param limitRow 限制值
* @return 按时间降序排列,小于输入值得第一个数据
*/
public List<Oil> queryNewestLt(String column, Object value, long limitRow) {
try {
return mDao.queryBuilder()
.orderBy("date",false)
.limit(limitRow)
.where()
.eq("isDelete", false).and()
.eq("isFull",true).and()
.lt(column, value)
.query();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
/** 按时间降序排序后查询按两个value之间的数据
* 并且isDelete=false
* @param column
* @param low high 包括low和high的值
* @return
*/
public List<Oil> queryBetween(String column, Object low,Object high) {
try {
return mDao.queryBuilder()
.orderBy("date",false)
.where()
.eq("isDelete", false).and()
.between(column,low,high)
.query();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
| [
"674079013@qq.com"
] | 674079013@qq.com |
625cd5534436ba540c27b069bae90baf42ed3ed8 | 8f634dfc515cf3d89241f88073f3a7c416e05404 | /src/com/class25/VehicleTest.java | 8a2d8bab7ff397d19152316b054c319f8ab7f03e | [] | no_license | shaistaaryan/JavaBasics | f3fd4c24cfabf045ebf98e20255e7d7717fc027b | 72be0c35b5a97c8604727f3c505d6706dced79e3 | refs/heads/master | 2021-05-19T16:48:36.794460 | 2020-04-19T15:38:54 | 2020-04-19T15:38:54 | 252,034,785 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 136 | java | package com.class25;
public class VehicleTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
| [
"shaistaaryan315@gmail.com"
] | shaistaaryan315@gmail.com |
e96ac8b48fd7fb6642b7dd47349e896b3ae95c1c | 1b6914f381718e248fed8100a6676891d5c281d5 | /src/main/java/ru/graduate/topjava/service/MealService.java | fd3e108dce098ccf02ea4fc43c2b3492feae5fea | [] | no_license | ArthursGitHub/GraduationProject | 08467ee23e0b6915f21de2d1b4fa18ad597e7da1 | 25911baecbd2f989072c4c0dac152fd50ef0e458 | refs/heads/master | 2020-03-08T05:24:34.076083 | 2018-04-19T00:10:09 | 2018-04-19T00:10:09 | 127,947,296 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 523 | java | package ru.graduate.topjava.service;
import ru.graduate.topjava.model.Meal;
import ru.graduate.topjava.util.exception.NotFoundException;
import java.time.LocalDate;
import java.util.List;
public interface MealService {
Meal get(int id, int cafeId) throws NotFoundException;
Meal create(Meal meal, int cafeId, LocalDate date);
Meal update(Meal meal, int cafeId, LocalDate date) throws NotFoundException;
List<Meal> getAll(int cafeId, LocalDate date);
void delete(int id, int cafeId) throws NotFoundException;
}
| [
"lebedev_a@parfum.spb.ru"
] | lebedev_a@parfum.spb.ru |
b7d287de03f4f3fad160e7030c5db6f22e22615c | a7fa899034f08ea7097444ee413eb841223a9805 | /app/src/test/java/id/ac/umn/uts_rubenrafferty_36238/ExampleUnitTest.java | 3a3121f62dee767ac2e309ab444929f8daaebf4f | [] | no_license | Rubenng72/UTSmobile | 10a0ab05ea851cb7f5adae1e18eddad47947ed92 | 284929357368d84a94f069c9793b47d9d06a7837 | refs/heads/main | 2023-08-12T02:53:14.078335 | 2021-10-06T09:30:19 | 2021-10-06T09:30:19 | 414,147,748 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 394 | java | package id.ac.umn.uts_rubenrafferty_36238;
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);
}
} | [
"ruben.rafferty@student.umn.ac.id"
] | ruben.rafferty@student.umn.ac.id |
a835a4ee3992f578f751b03066c5c0fb4ce53a36 | 8d774a80b6809c3b2147420655667f2d8bbc239a | /src/main/java/org/sonatype/se/hacks/lolz/Config.java | cd11c050ab9e530a1d974fe09aa0e2a48d6d914f | [] | no_license | HokieGeek/contained-billion-laughs | 128b82935d6c69143528ce00555976873faadba6 | 64a77c5aea0ae8d2567fa7cdf3e71367c311eceb | refs/heads/master | 2020-06-24T07:10:38.047730 | 2019-08-01T19:47:13 | 2019-08-01T19:47:13 | 198,890,637 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 148 | java | package org.sonatype.se.hacks.lolz;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement // (name = "config")
public class Config {
}
| [
"andres.f.perez@gmail.com"
] | andres.f.perez@gmail.com |
120ef5a1da519d4eb0f636c6924ce8979b7296e7 | 4b4376d689a0976eca333266422a0ed1bc6c7bf2 | /src/main/java/openmrsproject/dataAccess/abstracts/LoginDao.java | 1f7022e7e294cd5911733ae0fb7fdb20c1df1323 | [] | no_license | mert-uysal/openMRS-backend | 3720308068ad0d9ce1b694ae6c3b353d49bfb481 | b9359b5f00a866631deac20da59471b6deadb689 | refs/heads/main | 2023-08-28T14:09:50.992664 | 2021-10-18T12:24:31 | 2021-10-18T12:24:31 | 381,812,485 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 657 | java | package openmrsproject.dataAccess.abstracts;
import openmrsproject.entities.abstracts.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface LoginDao extends JpaRepository<User, Integer> {
User findUserByUsername (String username);
boolean existsUserByUsername (String username);
/*@Modifying
@Query(value = "select count(u) > 0 from User u where u.username = ?1", nativeQuery = true)
boolean isUsernameExist(String username);*/
}
| [
"68249841+mert-uysal@users.noreply.github.com"
] | 68249841+mert-uysal@users.noreply.github.com |
6a7426a26b60a7dd7547a9a9fd2ec240ef10aaf5 | d0b4a629a020dd3612c4ceb6e26e33dd247970e0 | /src/test/java/tests/TestClass.java | 35885e60964be93d077dcd7c45c61aaedeee95c2 | [
"MIT"
] | permissive | smartestautomation/effective_automation | d5ec5407c994a5f452c4a3f98d0493361a4e035d | 13826a3876a819d29940dd7d9dae630d26cb1200 | refs/heads/master | 2023-05-11T05:35:59.903426 | 2020-06-09T11:25:30 | 2020-06-09T11:25:30 | 270,980,795 | 0 | 0 | MIT | 2023-05-09T17:58:16 | 2020-06-09T11:12:40 | Java | UTF-8 | Java | false | false | 482 | java | package tests;
import driver.DriverManager;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
public class TestClass {
protected DriverManager driverManager;
static {
System.setProperty("appUrl", "https://google.com");
}
@BeforeClass
public void init() {
this.driverManager = new DriverManager();
}
@AfterClass
public void reset() {
driverManager.quit();
}
}
| [
"noreply@github.com"
] | noreply@github.com |
4b0b586a046e3eda74f111f443c6385a318df335 | 2f7f2c5e2ffcf7b181da2b966046605657ff9c40 | /wings/src/main/java/com/groundupworks/wings/IWingsLogger.java | 5c508f88eb51721d4b12e099b5887ad705f55314 | [
"Apache-2.0"
] | permissive | mullergt/wings | 4dad0ad8d5083500487c69ed157e40d27d41dbb6 | 7cb231cd5f641369e50881976c772c7733a85e40 | refs/heads/master | 2021-01-14T14:02:38.497857 | 2014-12-01T00:05:25 | 2014-12-01T00:05:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 997 | java | /*
* Copyright (C) 2014 Benedict Lau
*
* 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.groundupworks.wings;
/**
* An interface for printing logs.
*
* @author Benedict Lau
*/
public interface IWingsLogger {
/**
* Logs a debug message.
*
* @param clazz the {@link Class}.
* @param methodName the name of the method.
* @param msg the debug message.
*/
public void log(Class<?> clazz, String methodName, String msg);
}
| [
"ben.hy.lau@gmail.com"
] | ben.hy.lau@gmail.com |
6ef9aca30f708b82912c4a0ae052e779df14bdfa | 575d45ee84b80d5e0053be1e024cac4cd95ef163 | /src/main/java/uz/pdp/online/lesson_3_task_1_use_spring_security_pcmarket/projection/CustomInputProduct.java | d8e200a654205cae8c7e7580121c18f38e04c2e1 | [] | no_license | BaxtiyorWebDev/lesson_3_task_1_use_spring_security_pcmarket | aaf113903ea00d3d44256e2ec4143ea0e20daf66 | 4cfe496d4af4ac4d9d15fb44908cfb34c7dddd53 | refs/heads/master | 2023-04-12T07:47:51.917907 | 2021-05-22T12:28:29 | 2021-05-22T12:28:29 | 369,801,165 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 444 | java | package uz.pdp.online.lesson_3_task_1_use_spring_security_pcmarket.projection;
import org.springframework.data.rest.core.config.Projection;
import uz.pdp.online.lesson_3_task_1_use_spring_security_pcmarket.entity.InputProduct;
@Projection(types = InputProduct.class)
public interface CustomInputProduct {
Integer getId();
Integer getSupplier();
Integer getProductList();
Integer getQuantity();
Integer getAmount();
}
| [
"baxtiyor.08042000@gmail.com"
] | baxtiyor.08042000@gmail.com |
879b7c01703239d7d27f394666ab455c043bff29 | 25a6a6bae0492ac7c1b39cb63b6de1a9dd5065cf | /src/main/java/com/larodriguezm/appgate/service/IPAddressService.java | 691d80f607dae7b6fbc6fa6d55c01b2594f6382b | [] | no_license | maichel90/appgatechallenge | eb5d93e6655b3ca0935caadd565b48c888a98609 | a40d7189c6b9ade5f5cb2eefece5392c798bc8c1 | refs/heads/master | 2023-06-07T18:32:41.961293 | 2021-06-21T19:44:09 | 2021-06-21T19:44:09 | 378,448,727 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,067 | java | package com.larodriguezm.appgate.service;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import com.larodriguezm.appgate.dto.IPAddressDTO;
import com.larodriguezm.appgate.dto.ResponseSearchDTO;
import com.larodriguezm.appgate.exception.IPAddressException;
import com.larodriguezm.appgate.mapper.IResponseSearchMapper;
import com.larodriguezm.appgate.model.RangeIp;
import com.larodriguezm.appgate.repository.RangeRepository;
import com.larodriguezm.appgate.util.UtilIPAddress;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class IPAddressService {
@Autowired
private RangeRepository rangeRepository;
/**
* Metodo que realiza la validacion de la ip, realiza el calculo de la ip en
* decimal y la consulta en la base de datos para retornar datos de ubicacion de
* la ip
*
* @param ipAddressDTO DTO de entrada el cual contine la ip
* @return Lista de ResponseSearchDTO el cual retorna las posibles ubicaciones de la ip
*/
public List<ResponseSearchDTO> searchIpAddresLocation(IPAddressDTO ipAddressDTO) {
log.debug("Checking information to {}", ipAddressDTO.getIpaddress());
if (UtilIPAddress.validate(ipAddressDTO.getIpaddress())) {
Integer ipAddressDecimal = UtilIPAddress.ipAddressDecimal(ipAddressDTO.getIpaddress());
Optional<List<RangeIp>> optional = rangeRepository.findByDecimal(ipAddressDecimal, ipAddressDecimal);
if (optional.isPresent()) {
return IResponseSearchMapper.INSTANCE.entityToDTOList(optional.get());
}
log.debug("There is no information on the requested segment {}", ipAddressDTO.getIpaddress());
throw new IPAddressException("There is no information on the requested segment", HttpStatus.ACCEPTED, null);
}
log.debug("Incorrect format, please correct it and try again {}", ipAddressDTO.getIpaddress());
throw new IPAddressException("Incorrect format, please correct it and try again", HttpStatus.ACCEPTED, null);
}
}
| [
"lamaichel@stefanini.com"
] | lamaichel@stefanini.com |
c86d2ddfac38a439d1fdd1573df7f8a256e21214 | 9a4b0729b10db5480af0ffcc293b8b0dc0a60f6d | /Hans/CampusApp1.6.1/src/de/ur/mi/mspwddhs/campusapp/grips/GradesParseController.java | f190885a92f3211c66436f3ec69cfbef75a44a00 | [] | no_license | Kinderfest/Uni | 09c6610e7c7a6e8be414140565db05aabb153c74 | ef9e5d33093251b50250f01dcdad46065ab3bcd9 | refs/heads/master | 2021-01-10T20:22:41.048601 | 2014-11-10T13:13:44 | 2014-11-10T13:13:44 | 22,720,555 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,273 | java | package de.ur.mi.mspwddhs.campusapp.grips;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import android.os.AsyncTask;
public class GradesParseController {
private ArrayList<Grades> myGrades;
private GradesParseListener listener;
public GradesParseController(GradesParseListener listener) {
this.listener = listener;
}
public void initialize(String url) {
myGrades = new ArrayList<Grades>();
new ParseGrades().execute(url);
}
public interface GradesParseListener {
public String getPass();
public String getUser();
public void onGradesDownloadCompleted(ArrayList<Grades> data);
}
private class ParseGrades extends AsyncTask<String, String, String> {
private CookieStore cookieStore;
@Override
protected String doInBackground(String... params) {
String username = listener.getUser();
String password = listener.getPass();
String url = params[0];
String loginHtml = loginToGrips(ParseController.domainName,
username, password);
String html = getHttpFromUrl(url);
parseForum(html);
return null;
}
@Override
protected void onPostExecute(String result) {
listener.onGradesDownloadCompleted(myGrades);
}
private String loginToGrips(String url, String username, String password) {
String result = "";
cookieStore = new BasicCookieStore();
AbstractHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
try {
final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("realm", "ur"));
nameValuePairs
.add(new BasicNameValuePair("username", username));
nameValuePairs
.add(new BasicNameValuePair("password", password));
nameValuePairs.add(new BasicNameValuePair("rememberusername",
"1"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
cookieStore = client.getCookieStore();
} catch (final IOException e) {
e.printStackTrace();
}
return "";
}
private String getHttpFromUrl(String url) {
String result = "";
@SuppressWarnings("resource")
AbstractHttpClient client = new DefaultHttpClient();
client.setCookieStore(cookieStore);
HttpPost post = new HttpPost(url);
try {
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
result += line;
}
} catch (final IOException e) {
e.printStackTrace();
}
return result;
}
private void parseForum(String html) {
Document doc = Jsoup.parse(html);
Element forum = doc.getElementsByTag("table")
.select(".boxaligncenter").first();
Elements rows = forum.getElementsByTag("tr");
for (Element row : rows) {
Element taskname = null;
String points = "";
String range = "";
String percentile = "";
String feedback = "";
try {
taskname = row.select(".item").select("a[href]").first();
points = row.select("[headers*=grade]").text();
range = row.select("[headers'=range]").text();
percentile = row.select("[headers*=percentage]").text();
feedback = row.select("[headers*=feedback]").text();
} catch (Exception e) {
}
if (taskname != null) {
myGrades.add(new Grades(taskname.text(), points, range,
percentile, feedback));
}
}
}
}
}
| [
"Maike@maikes-mbp-2.fritz.box"
] | Maike@maikes-mbp-2.fritz.box |
c2263a30ec5a27e40e469aa08e9e7fe514a1d9ab | cd11dc087e33fc6977a0962badf6301d92f51667 | /Part1/ParseError.java | be57755d923ae0ff1cad387aa7e3a660cca9d8d0 | [] | no_license | chrysr/CompilersEx | be8680fd40315d73512b7a6f74bdbb115b8ebdaa | 14010258c616ff325d80175691b7498e0d56bcc7 | refs/heads/master | 2021-10-24T23:20:46.956196 | 2019-03-29T18:44:54 | 2019-03-29T18:44:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 109 | java | public class ParseError extends Exception {
public String getMessage() {
return "Parse Εrror";
}
} | [
"noreply@github.com"
] | noreply@github.com |
7987554c2149df3628298af9602b5c40d1c98f4e | c55a758da768c00779aeb23f617e8883bde78d99 | /dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/programrule/ProgramRuleActionStoreTest.java | 31f5fd942dcac58b916cc56ba39fe0ac8250a72c | [
"BSD-3-Clause"
] | permissive | kakada/dhis2 | 2d229dad0a835e711c7c8923ba9ffd5c2845f462 | 7a47bad654a340a5c2bcfa0de936f4fdc885ca5e | refs/heads/master | 2021-01-18T22:41:04.575412 | 2015-07-24T07:10:46 | 2015-07-24T07:10:46 | 39,616,913 | 0 | 1 | null | 2016-03-09T19:45:40 | 2015-07-24T07:01:37 | Java | UTF-8 | Java | false | false | 3,775 | java | package org.hisp.dhis.programrule;
/*
* Copyright (c) 2004-2015, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ProgramRuleActionStoreTest
extends DhisSpringTest
{
private ProgramRule programRuleA;
private DataElement dataElementA;
private Program programA;
@Autowired
public ProgramRuleStore programRuleStore;
@Autowired
public DataElementService dataElementService;
@Autowired
public ProgramRuleActionStore actionStore;
@Autowired
private ProgramService programService;
@Override
public void setUpTest()
{
programA = createProgram( 'A', null, null );
programRuleA = createProgramRule( 'A', programA );
dataElementA = createDataElement( 'A' );
programService.addProgram( programA );
programRuleStore.save( programRuleA );
dataElementService.addDataElement( dataElementA );
}
@Test
public void testGetByProgram()
{
ProgramRuleAction actionA = new ProgramRuleAction( "ActionA", programRuleA, ProgramRuleActionType.ASSIGNVARIABLE, null, null, "$myvar", "true");
ProgramRuleAction actionB = new ProgramRuleAction( "ActionB", programRuleA, ProgramRuleActionType.DISPLAYTEXT, null, "con","Hello", "$placeofliving");
ProgramRuleAction actionC = new ProgramRuleAction( "ActionC", programRuleA, ProgramRuleActionType.HIDEFIELD, dataElementA, null, null, null);
actionStore.save( actionA );
actionStore.save( actionB );
actionStore.save( actionC );
Collection<ProgramRuleAction> vars = actionStore.get( programRuleA );
assertEquals( 3, vars.size() );
assertTrue( vars.contains( actionA ) );
assertTrue( vars.contains( actionB ) );
assertTrue( vars.contains( actionC ) );
}
}
| [
"kakada.chheang@gmail.com"
] | kakada.chheang@gmail.com |
75cf6d4ba75f76b5e14d4066f54f51f37fdcee81 | 4d00d94757d52791fd928d5630b4fa00014bfe01 | /src/main/java/com/la/movie/day/domain/dto/CinemaListDto.java | 1a29ec4575659d42a1a8db6e30cc6e4ecf9dca46 | [] | no_license | LucyAm/movie-day | 5e4afde3fc960e73dc7bc9e002ff91116d9845d5 | 60a8470d6e597ca3ac08edfd96e4ea32a5b5a062 | refs/heads/master | 2020-03-20T09:38:02.593139 | 2018-06-14T13:18:57 | 2018-06-14T13:18:57 | 137,343,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 395 | java | package com.la.movie.day.domain.dto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
@NoArgsConstructor
@Getter
@Setter
public class CinemaListDto implements Serializable {
private long id;
private String name;
private String address;
private String phone;
private String siteUrl;
private String openClosed;
}
| [
"lusysargsyan97@gmail.com"
] | lusysargsyan97@gmail.com |
7596b9e5acefef8beeb62db392155fa05a29f51d | 270a84f6182e330be71fe4a70056bba2866f7844 | /Functional/src/main/java/refactula/functional/case_class/CaseClassSupervisorPool.java | 1f96fba9e62d1e04845155d7362ce1c0ca4f19c1 | [] | no_license | Refactula/1MLoC | f63c4a98184f89c6d46499c09ead7bb1d9ea1e14 | c4a49ab7c7281889041e62d8e5bf862280bafda2 | refs/heads/master | 2021-01-22T05:43:33.572996 | 2017-03-20T11:17:20 | 2017-03-20T11:48:15 | 81,690,389 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 464 | java | package refactula.functional.case_class;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
class CaseClassSupervisorPool {
private static final ConcurrentMap<Class, CaseClassSupervisor> pool = new ConcurrentHashMap<>();
@SuppressWarnings("unchecked")
static <C extends CaseType<C>> CaseClassSupervisor<C> forClass(Class<C> cls) {
return pool.computeIfAbsent(cls, CaseClassSupervisor::create);
}
}
| [
"refactula@gmail.com"
] | refactula@gmail.com |
f3cc7b7d55da20e726ac8828de2e8a7e8edc5d20 | 21c1b4ad3d887ba3f08e914389cef64a5090179d | /basic-code/src/main/java/com/basiccode/jvmcode/JvmDemo1.java | 39130c1f878f985d3804d679131017f97858c0e3 | [
"MIT"
] | permissive | wenzhi123/java-tutorial | 95cf4a99c131f8e810abf3c0ef1d00e654aaeb9d | c17f4f43a0cf66c0836616bbf7b9a6bb651cfa40 | refs/heads/master | 2020-04-23T07:25:45.464742 | 2018-11-14T08:49:48 | 2018-11-14T08:49:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,401 | java | package com.basiccode.jvmcode;
class Grandpa1 {
static {
System.out.println("爷爷在静态代码块");
}
public Grandpa1() {
System.out.println("我是爷爷~");
}
}
class Father1 extends Grandpa1 {
static {
System.out.println("爸爸在静态代码块");
}
public Father1() {
System.out.println("我是爸爸~");
}
}
class Son1 extends Father1 {
static {
System.out.println("儿子在静态代码块");
}
public Son1() {
System.out.println("我是儿子~");
}
}
/**
* @author : Jarvis
* @date : 2018/6/14
*/
public class JvmDemo1 {
/**
* 分析:
* 首先在入口这里我们实例化一个 Son 对象,因此会触发 Son 类的初始化,而 Son 类的初始化又会带动 Father 、Grandpa 类的初始化,
* 从而执行对应类中的静态代码块。因此会输出:「爷爷在静态代码块」、「爸爸在静态代码块」、「儿子在静态代码块」。
* 当 Son 类完成初始化之后,便会调用 Son 类的构造方法,而 Son 类构造方法的调用同样会带动 Father、Grandpa 类构造方法的调用,
* 最后会输出:「我是爷爷~」、「我是爸爸~」、「我是儿子~」。
*
* @param args
*/
public static void main(String[] args) {
//入口
new Son1();
}
}
| [
"qdw8911@sina.com"
] | qdw8911@sina.com |
062d974f7a3a2b5d0466390977af4e4d3ca50af0 | c84088fed6a7b4f392810bb166e66dbfe3df4286 | /Morning/morning-cms-web/src/main/java/org/pussinboots/morning/cms/common/util/ServletUtils.java | e6d2035b6389b129a82f24fc964df333b87da8f0 | [] | no_license | 1Will/Work1 | 4c419b9013d2989c4bbe6721c155de609e5ce9b5 | 16e707588da13e9dede5f7de97ca53e15a7d5a78 | refs/heads/master | 2020-05-22T16:52:56.501596 | 2018-03-20T01:21:01 | 2018-03-20T01:21:01 | 84,697,600 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,796 | java | package org.pussinboots.morning.cms.common.util;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.StringTokenizer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import eu.bitwalker.useragentutils.Browser;
import eu.bitwalker.useragentutils.OperatingSystem;
import eu.bitwalker.useragentutils.UserAgent;
/**
*
* 项目名称:morning-cms-web Maven Webapp
* 类名称:ServletUtils
* 类描述:ServletUtils工具类:提供一些Http与Servlet工具的方法
* 创建人:陈星星
* 创建时间:2017年4月1日 下午4:20:00
*
*/
public class ServletUtils {
private static Logger logger = LoggerFactory.getLogger(ServletUtils.class);
// -- Content Type 定义 --//
public static final String EXCEL_TYPE = "application/vnd.ms-excel";
public static final String HTML_TYPE = "text/html";
public static final String JS_TYPE = "text/javascript";
public static final String JSON_TYPE = "application/json";
public static final String XML_TYPE = "text/xml";
public static final String TEXT_TYPE = "text/plain";
// -- Header 定义 --//
public static final String AUTHENTICATION_HEADER = "Authorization";
private ServletUtils() {
throw new AssertionError();
}
/**
* 设置客户端缓存过期时间 的Header.
*/
public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) {
// Http 1.0 header
response.setDateHeader("Expires", System.currentTimeMillis() + expiresSeconds * 1000);
// Http 1.1 header
response.setHeader("Cache-Control", "private, max-age=" + expiresSeconds);
}
/**
* 设置禁止客户端缓存的Header.
*/
public static void setDisableCacheHeader(HttpServletResponse response) {
// Http 1.0 header
response.setDateHeader("Expires", 1L);
response.addHeader("Pragma", "no-cache");
// Http 1.1 header
response.setHeader("Cache-Control", "no-cache, no-store, max-age=0");
}
/**
* 设置LastModified Header.
*/
public static void setLastModifiedHeader(HttpServletResponse response, long lastModifiedDate) {
response.setDateHeader("Last-Modified", lastModifiedDate);
}
/**
* 设置Etag Header.
*/
public static void setEtag(HttpServletResponse response, String etag) {
response.setHeader("ETag", etag);
}
/**
* 根据浏览器If-Modified-Since Header, 计算文件是否已被修改.
* 如果无修改, checkIfModify返回false ,设置304 not modify status.
* @param lastModified 内容的最后修改时间.
*/
public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response,
long lastModified) {
long ifModifiedSince = request.getDateHeader("If-Modified-Since");
if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return false;
}
return true;
}
/**
* 根据浏览器 If-None-Match Header, 计算Etag是否已无效.
* 如果Etag有效, checkIfNoneMatch返回false, 设置304 not modify status.
* @param etag 内容的ETag.
*/
public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) {
String headerValue = request.getHeader("If-None-Match");
if (headerValue != null) {
boolean conditionSatisfied = false;
if (!"*".equals(headerValue)) {
StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
String currentToken = commaTokenizer.nextToken();
if (currentToken.trim().equals(etag)) {
conditionSatisfied = true;
}
}
} else {
conditionSatisfied = true;
}
if (conditionSatisfied) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
response.setHeader("ETag", etag);
return false;
}
}
return true;
}
/**
* 设置让浏览器弹出下载对话框的Header.
* @param fileName 下载后的文件名.
*/
public static void setFileDownloadHeader(HttpServletResponse response, String fileName) {
try {
// 中文文件名支持
String encodedfileName = new String(fileName.getBytes(), "ISO8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedfileName + "\"");
} catch (UnsupportedEncodingException e) {
logger.error("ServletUtils.setFileDownloadHeader", e);
}
}
/**
* 获取当前请求对象
*/
public static HttpServletRequest getRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
/**
* 获取项目名称路径
*/
public static String getContentpath() {
return getRequest().getContextPath();
}
/**
* 获取项目绝对路径
*/
public static String getRealPath() {
return getRequest().getSession().getServletContext().getRealPath("/");
}
/**
* getAttribute这个方法是提取放置在某个共享区间的对象
* @param name
* @return
*/
public static Object getAttribute(String name) {
return getRequest().getSession().getAttribute(name);
}
/**
* getParameter系列的方法主要用于处理“请求数据”,是服务器端程序获取浏览器所传递参数的主要接口。
* @param name 表单name属性
* @return
*/
public static String getParameter(String name) {
return getRequest().getParameter(name);
}
/**
* getParameterValues这个方法是获得传过来的参数名相同的一个数组;
* @param name
* @return
*/
public static String[] getParameterValues(String name) {
return getRequest().getParameterValues(name);
}
/**
* 获取当前网络ip
* @return
*/
public static String getIpAddr() {
String ipAddress = getRequest().getHeader("x-forwarded-for");
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = getRequest().getHeader("Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = getRequest().getHeader("WL-Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = getRequest().getRemoteAddr();
if ("127.0.0.1".equals(ipAddress) || "0:0:0:0:0:0:0:1".equals(ipAddress)) {
// 根据网卡取本机配置的IP
InetAddress inet = null;
try {
inet = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
logger.error("ServletUtils.getIpAddr", e);
}
ipAddress = inet.getHostAddress();
}
}
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if (ipAddress != null && ipAddress.length() > 15 && ipAddress.indexOf(',') > 0) { // "***.***.***.***".length() // = 15
ipAddress = ipAddress.substring(0, ipAddress.indexOf(','));
}
return ipAddress;
}
/**
* 获取当前用户游览器型号
*/
public static String getUserBrowser() {
UserAgent userAgent = UserAgent.parseUserAgentString(getRequest().getHeader("User-Agent"));
Browser browser = userAgent.getBrowser();
return browser.toString();
}
/**
* 获取当前用户系统型号
*/
public static String getUserOperatingSystem() {
UserAgent userAgent = UserAgent.parseUserAgentString(getRequest().getHeader("User-Agent"));
OperatingSystem operatingSystem = userAgent.getOperatingSystem();
return operatingSystem.toString();
}
} | [
"287463504@qq.com"
] | 287463504@qq.com |
3716d72edd08989a5b17fc1507f57ef15e5046d9 | c5bae7c79fc1597afe0b9bcaf97b16e58d5d0d62 | /hw07/src/Knapsack.java | 23f6dfa5b843c3bcd8076a68a267656e86e9b9b2 | [] | no_license | GoodLuckDay/AlgorithmClass | 9c31086069b4806e686cdfb3e9c1a027b269a4f7 | 4bb7f2463503dbfb7b953b891ca9e56c42f0c71f | refs/heads/master | 2021-08-28T15:31:07.882946 | 2017-12-12T16:21:28 | 2017-12-12T16:21:28 | 103,500,051 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,757 | java | import java.util.*;
public class Knapsack {
static Scanner scanner = new Scanner(System.in);
static Item[] items;
static int[][] answer;
static int N, W;
public static void main(String[] args) {
N = scanner.nextInt();
W = scanner.nextInt();
inputItems();
solve();
printMaxItems();
}
private static void printMaxItems() {
System.out.println("max : "+ answer[N][W]);
System.out.print("item : ");
int i=N, j=W;
while(i!=0 && j!=0){
if(answer[i][j] != answer[i-1][j]){
System.out.print(i+" ");
j = j - items[i].weight;
}
i = i-1;
}
}
private static void solve() {
for(int i=0; i<=N; i++){
for(int j=0; j<=W; j++){
if(i == 0){
answer[i][j] = 0;
}
else if(items[i].weight > j){
answer[i][j] = answer[i-1][j];
}
else{
answer[i][j] = Integer.max(answer[i-1][j], answer[i-1][j-items[i].weight] + items[i].value);
}
System.out.printf("\t"+ answer[i][j]+"\t");
}
System.out.println();
}
}
private static void inputItems() {
items = new Item[N+1];
answer = new int[N+1][W+1];
for(int i=1; i<=N; i++){
int inputValue = scanner.nextInt();
int inputWeight = scanner.nextInt();
items[i] = new Item(inputValue, inputWeight);
}
}
}
class Item{
int value;
int weight;
public Item(int value, int weight){
this.value = value;
this.weight = weight;
}
}
| [
"haon4658@gmail.com"
] | haon4658@gmail.com |
e321d50b88a404fb9ee0101a065d2703f40addfb | eb0258917fb51098b14654f40ac193d7a6c7a2f6 | /src/main/java/com/team1816/lib/subsystems/DifferentialDrivetrain.java | 124ba82b638170387e249243e8e8a10572445655 | [] | no_license | TheGreenMachine/Zodiac | 065984dd3b086350ae2b63decdc517d50d9c2405 | 83ba5a27773ccde135d32eaf2a7a5228f678949a | refs/heads/main | 2022-12-21T07:48:31.143758 | 2022-01-19T01:58:07 | 2022-01-19T01:58:07 | 228,888,549 | 4 | 5 | null | 2022-12-16T08:18:55 | 2019-12-18T17:19:56 | Java | UTF-8 | Java | false | false | 415 | java | package com.team1816.lib.subsystems;
public interface DifferentialDrivetrain extends TrackableDrivetrain {
double getLeftVelocityNativeUnits();
double getRightVelocityNativeUnits();
double getLeftVelocityDemand();
double getRightVelocityDemand();
double getLeftVelocityError();
double getRightVelocityError();
double getLeftEncoderDistance();
double getRightEncoderDistance();
}
| [
"sc.richik@gmail.com"
] | sc.richik@gmail.com |
3d8017a416de51fdcc52d89e19354d83dfc57ecb | f90cc2a9f7a6877d18a4fdfa1a0a048be6d3604e | /src/main/java/pages/FileUploadPage.java | fa91db6c3cd70432920b8e8275af20720f8ff29a | [] | no_license | NickBaynham/testautomation | e976b541c4f68004238acf8004c30ad169a0cfab | c1dc13f219683ac08708b7636a4db0ac5575a45d | refs/heads/master | 2023-07-26T01:08:21.301986 | 2023-07-06T20:54:23 | 2023-07-06T20:54:23 | 229,487,842 | 0 | 0 | null | 2023-07-06T20:54:03 | 2019-12-21T21:57:12 | Java | UTF-8 | Java | false | false | 752 | java | package pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class FileUploadPage {
private WebDriver driver;
private By inputField = By.id("file-upload");
private By uploadButton = By.id("file-submit");
private By uploadedFiles = By.id("uploaded-files");
public FileUploadPage(WebDriver driver) {
this.driver = driver;
}
public void clickUploadButton() {
driver.findElement(uploadButton).click();
}
public void uploadFile(String absolutePathOfFile) {
driver.findElement(inputField).sendKeys(absolutePathOfFile);
clickUploadButton();
}
public String getUploadedFiles() {
return driver.findElement(uploadedFiles).getText();
}
}
| [
"nbaynham@flhi.com"
] | nbaynham@flhi.com |
857d2e78abeda69093b138b555ed98109ed30ed1 | 66d2fd4aa2b32ed824abec37057545ba8ea57111 | /tms-commons/src/main/java/com/karsait/tms/entity/TicketOutRecordExample.java | 79ae660564a29232e205a0a496fd04831651c52a | [] | no_license | pythonking/tms | b3fbda3bb085108eba4027e61d6630dc76573e03 | 953d9795131889b11c9b9ed6daf0d2b1567f586e | refs/heads/master | 2020-03-26T19:40:08.244781 | 2018-12-24T02:39:40 | 2018-12-24T02:39:40 | 145,276,274 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 44,826 | java | package com.karsait.tms.entity;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class TicketOutRecordExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TicketOutRecordExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andOutAccountNameIsNull() {
addCriterion("out_account_name is null");
return (Criteria) this;
}
public Criteria andOutAccountNameIsNotNull() {
addCriterion("out_account_name is not null");
return (Criteria) this;
}
public Criteria andOutAccountNameEqualTo(String value) {
addCriterion("out_account_name =", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameNotEqualTo(String value) {
addCriterion("out_account_name <>", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameGreaterThan(String value) {
addCriterion("out_account_name >", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameGreaterThanOrEqualTo(String value) {
addCriterion("out_account_name >=", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameLessThan(String value) {
addCriterion("out_account_name <", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameLessThanOrEqualTo(String value) {
addCriterion("out_account_name <=", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameLike(String value) {
addCriterion("out_account_name like", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameNotLike(String value) {
addCriterion("out_account_name not like", value, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameIn(List<String> values) {
addCriterion("out_account_name in", values, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameNotIn(List<String> values) {
addCriterion("out_account_name not in", values, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameBetween(String value1, String value2) {
addCriterion("out_account_name between", value1, value2, "outAccountName");
return (Criteria) this;
}
public Criteria andOutAccountNameNotBetween(String value1, String value2) {
addCriterion("out_account_name not between", value1, value2, "outAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameIsNull() {
addCriterion("finance_account_name is null");
return (Criteria) this;
}
public Criteria andFinanceAccountNameIsNotNull() {
addCriterion("finance_account_name is not null");
return (Criteria) this;
}
public Criteria andFinanceAccountNameEqualTo(String value) {
addCriterion("finance_account_name =", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameNotEqualTo(String value) {
addCriterion("finance_account_name <>", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameGreaterThan(String value) {
addCriterion("finance_account_name >", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameGreaterThanOrEqualTo(String value) {
addCriterion("finance_account_name >=", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameLessThan(String value) {
addCriterion("finance_account_name <", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameLessThanOrEqualTo(String value) {
addCriterion("finance_account_name <=", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameLike(String value) {
addCriterion("finance_account_name like", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameNotLike(String value) {
addCriterion("finance_account_name not like", value, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameIn(List<String> values) {
addCriterion("finance_account_name in", values, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameNotIn(List<String> values) {
addCriterion("finance_account_name not in", values, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameBetween(String value1, String value2) {
addCriterion("finance_account_name between", value1, value2, "financeAccountName");
return (Criteria) this;
}
public Criteria andFinanceAccountNameNotBetween(String value1, String value2) {
addCriterion("finance_account_name not between", value1, value2, "financeAccountName");
return (Criteria) this;
}
public Criteria andStateIsNull() {
addCriterion("state is null");
return (Criteria) this;
}
public Criteria andStateIsNotNull() {
addCriterion("state is not null");
return (Criteria) this;
}
public Criteria andStateEqualTo(String value) {
addCriterion("state =", value, "state");
return (Criteria) this;
}
public Criteria andStateNotEqualTo(String value) {
addCriterion("state <>", value, "state");
return (Criteria) this;
}
public Criteria andStateGreaterThan(String value) {
addCriterion("state >", value, "state");
return (Criteria) this;
}
public Criteria andStateGreaterThanOrEqualTo(String value) {
addCriterion("state >=", value, "state");
return (Criteria) this;
}
public Criteria andStateLessThan(String value) {
addCriterion("state <", value, "state");
return (Criteria) this;
}
public Criteria andStateLessThanOrEqualTo(String value) {
addCriterion("state <=", value, "state");
return (Criteria) this;
}
public Criteria andStateLike(String value) {
addCriterion("state like", value, "state");
return (Criteria) this;
}
public Criteria andStateNotLike(String value) {
addCriterion("state not like", value, "state");
return (Criteria) this;
}
public Criteria andStateIn(List<String> values) {
addCriterion("state in", values, "state");
return (Criteria) this;
}
public Criteria andStateNotIn(List<String> values) {
addCriterion("state not in", values, "state");
return (Criteria) this;
}
public Criteria andStateBetween(String value1, String value2) {
addCriterion("state between", value1, value2, "state");
return (Criteria) this;
}
public Criteria andStateNotBetween(String value1, String value2) {
addCriterion("state not between", value1, value2, "state");
return (Criteria) this;
}
public Criteria andContentIsNull() {
addCriterion("content is null");
return (Criteria) this;
}
public Criteria andContentIsNotNull() {
addCriterion("content is not null");
return (Criteria) this;
}
public Criteria andContentEqualTo(String value) {
addCriterion("content =", value, "content");
return (Criteria) this;
}
public Criteria andContentNotEqualTo(String value) {
addCriterion("content <>", value, "content");
return (Criteria) this;
}
public Criteria andContentGreaterThan(String value) {
addCriterion("content >", value, "content");
return (Criteria) this;
}
public Criteria andContentGreaterThanOrEqualTo(String value) {
addCriterion("content >=", value, "content");
return (Criteria) this;
}
public Criteria andContentLessThan(String value) {
addCriterion("content <", value, "content");
return (Criteria) this;
}
public Criteria andContentLessThanOrEqualTo(String value) {
addCriterion("content <=", value, "content");
return (Criteria) this;
}
public Criteria andContentLike(String value) {
addCriterion("content like", value, "content");
return (Criteria) this;
}
public Criteria andContentNotLike(String value) {
addCriterion("content not like", value, "content");
return (Criteria) this;
}
public Criteria andContentIn(List<String> values) {
addCriterion("content in", values, "content");
return (Criteria) this;
}
public Criteria andContentNotIn(List<String> values) {
addCriterion("content not in", values, "content");
return (Criteria) this;
}
public Criteria andContentBetween(String value1, String value2) {
addCriterion("content between", value1, value2, "content");
return (Criteria) this;
}
public Criteria andContentNotBetween(String value1, String value2) {
addCriterion("content not between", value1, value2, "content");
return (Criteria) this;
}
public Criteria andBeginTicketNumIsNull() {
addCriterion("begin_ticket_num is null");
return (Criteria) this;
}
public Criteria andBeginTicketNumIsNotNull() {
addCriterion("begin_ticket_num is not null");
return (Criteria) this;
}
public Criteria andBeginTicketNumEqualTo(String value) {
addCriterion("begin_ticket_num =", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumNotEqualTo(String value) {
addCriterion("begin_ticket_num <>", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumGreaterThan(String value) {
addCriterion("begin_ticket_num >", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumGreaterThanOrEqualTo(String value) {
addCriterion("begin_ticket_num >=", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumLessThan(String value) {
addCriterion("begin_ticket_num <", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumLessThanOrEqualTo(String value) {
addCriterion("begin_ticket_num <=", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumLike(String value) {
addCriterion("begin_ticket_num like", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumNotLike(String value) {
addCriterion("begin_ticket_num not like", value, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumIn(List<String> values) {
addCriterion("begin_ticket_num in", values, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumNotIn(List<String> values) {
addCriterion("begin_ticket_num not in", values, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumBetween(String value1, String value2) {
addCriterion("begin_ticket_num between", value1, value2, "beginTicketNum");
return (Criteria) this;
}
public Criteria andBeginTicketNumNotBetween(String value1, String value2) {
addCriterion("begin_ticket_num not between", value1, value2, "beginTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumIsNull() {
addCriterion("end_ticket_num is null");
return (Criteria) this;
}
public Criteria andEndTicketNumIsNotNull() {
addCriterion("end_ticket_num is not null");
return (Criteria) this;
}
public Criteria andEndTicketNumEqualTo(String value) {
addCriterion("end_ticket_num =", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumNotEqualTo(String value) {
addCriterion("end_ticket_num <>", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumGreaterThan(String value) {
addCriterion("end_ticket_num >", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumGreaterThanOrEqualTo(String value) {
addCriterion("end_ticket_num >=", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumLessThan(String value) {
addCriterion("end_ticket_num <", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumLessThanOrEqualTo(String value) {
addCriterion("end_ticket_num <=", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumLike(String value) {
addCriterion("end_ticket_num like", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumNotLike(String value) {
addCriterion("end_ticket_num not like", value, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumIn(List<String> values) {
addCriterion("end_ticket_num in", values, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumNotIn(List<String> values) {
addCriterion("end_ticket_num not in", values, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumBetween(String value1, String value2) {
addCriterion("end_ticket_num between", value1, value2, "endTicketNum");
return (Criteria) this;
}
public Criteria andEndTicketNumNotBetween(String value1, String value2) {
addCriterion("end_ticket_num not between", value1, value2, "endTicketNum");
return (Criteria) this;
}
public Criteria andTotalNumIsNull() {
addCriterion("total_num is null");
return (Criteria) this;
}
public Criteria andTotalNumIsNotNull() {
addCriterion("total_num is not null");
return (Criteria) this;
}
public Criteria andTotalNumEqualTo(Integer value) {
addCriterion("total_num =", value, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumNotEqualTo(Integer value) {
addCriterion("total_num <>", value, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumGreaterThan(Integer value) {
addCriterion("total_num >", value, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumGreaterThanOrEqualTo(Integer value) {
addCriterion("total_num >=", value, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumLessThan(Integer value) {
addCriterion("total_num <", value, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumLessThanOrEqualTo(Integer value) {
addCriterion("total_num <=", value, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumIn(List<Integer> values) {
addCriterion("total_num in", values, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumNotIn(List<Integer> values) {
addCriterion("total_num not in", values, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumBetween(Integer value1, Integer value2) {
addCriterion("total_num between", value1, value2, "totalNum");
return (Criteria) this;
}
public Criteria andTotalNumNotBetween(Integer value1, Integer value2) {
addCriterion("total_num not between", value1, value2, "totalNum");
return (Criteria) this;
}
public Criteria andPriceIsNull() {
addCriterion("price is null");
return (Criteria) this;
}
public Criteria andPriceIsNotNull() {
addCriterion("price is not null");
return (Criteria) this;
}
public Criteria andPriceEqualTo(BigDecimal value) {
addCriterion("price =", value, "price");
return (Criteria) this;
}
public Criteria andPriceNotEqualTo(BigDecimal value) {
addCriterion("price <>", value, "price");
return (Criteria) this;
}
public Criteria andPriceGreaterThan(BigDecimal value) {
addCriterion("price >", value, "price");
return (Criteria) this;
}
public Criteria andPriceGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("price >=", value, "price");
return (Criteria) this;
}
public Criteria andPriceLessThan(BigDecimal value) {
addCriterion("price <", value, "price");
return (Criteria) this;
}
public Criteria andPriceLessThanOrEqualTo(BigDecimal value) {
addCriterion("price <=", value, "price");
return (Criteria) this;
}
public Criteria andPriceIn(List<BigDecimal> values) {
addCriterion("price in", values, "price");
return (Criteria) this;
}
public Criteria andPriceNotIn(List<BigDecimal> values) {
addCriterion("price not in", values, "price");
return (Criteria) this;
}
public Criteria andPriceBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("price between", value1, value2, "price");
return (Criteria) this;
}
public Criteria andPriceNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("price not between", value1, value2, "price");
return (Criteria) this;
}
public Criteria andTotalPriceIsNull() {
addCriterion("total_price is null");
return (Criteria) this;
}
public Criteria andTotalPriceIsNotNull() {
addCriterion("total_price is not null");
return (Criteria) this;
}
public Criteria andTotalPriceEqualTo(BigDecimal value) {
addCriterion("total_price =", value, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceNotEqualTo(BigDecimal value) {
addCriterion("total_price <>", value, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceGreaterThan(BigDecimal value) {
addCriterion("total_price >", value, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("total_price >=", value, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceLessThan(BigDecimal value) {
addCriterion("total_price <", value, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceLessThanOrEqualTo(BigDecimal value) {
addCriterion("total_price <=", value, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceIn(List<BigDecimal> values) {
addCriterion("total_price in", values, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceNotIn(List<BigDecimal> values) {
addCriterion("total_price not in", values, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("total_price between", value1, value2, "totalPrice");
return (Criteria) this;
}
public Criteria andTotalPriceNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("total_price not between", value1, value2, "totalPrice");
return (Criteria) this;
}
public Criteria andStoreAccountNameIsNull() {
addCriterion("store_account_name is null");
return (Criteria) this;
}
public Criteria andStoreAccountNameIsNotNull() {
addCriterion("store_account_name is not null");
return (Criteria) this;
}
public Criteria andStoreAccountNameEqualTo(String value) {
addCriterion("store_account_name =", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameNotEqualTo(String value) {
addCriterion("store_account_name <>", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameGreaterThan(String value) {
addCriterion("store_account_name >", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameGreaterThanOrEqualTo(String value) {
addCriterion("store_account_name >=", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameLessThan(String value) {
addCriterion("store_account_name <", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameLessThanOrEqualTo(String value) {
addCriterion("store_account_name <=", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameLike(String value) {
addCriterion("store_account_name like", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameNotLike(String value) {
addCriterion("store_account_name not like", value, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameIn(List<String> values) {
addCriterion("store_account_name in", values, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameNotIn(List<String> values) {
addCriterion("store_account_name not in", values, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameBetween(String value1, String value2) {
addCriterion("store_account_name between", value1, value2, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountNameNotBetween(String value1, String value2) {
addCriterion("store_account_name not between", value1, value2, "storeAccountName");
return (Criteria) this;
}
public Criteria andStoreAccountIdIsNull() {
addCriterion("store_account_id is null");
return (Criteria) this;
}
public Criteria andStoreAccountIdIsNotNull() {
addCriterion("store_account_id is not null");
return (Criteria) this;
}
public Criteria andStoreAccountIdEqualTo(Integer value) {
addCriterion("store_account_id =", value, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdNotEqualTo(Integer value) {
addCriterion("store_account_id <>", value, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdGreaterThan(Integer value) {
addCriterion("store_account_id >", value, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdGreaterThanOrEqualTo(Integer value) {
addCriterion("store_account_id >=", value, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdLessThan(Integer value) {
addCriterion("store_account_id <", value, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdLessThanOrEqualTo(Integer value) {
addCriterion("store_account_id <=", value, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdIn(List<Integer> values) {
addCriterion("store_account_id in", values, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdNotIn(List<Integer> values) {
addCriterion("store_account_id not in", values, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdBetween(Integer value1, Integer value2) {
addCriterion("store_account_id between", value1, value2, "storeAccountId");
return (Criteria) this;
}
public Criteria andStoreAccountIdNotBetween(Integer value1, Integer value2) {
addCriterion("store_account_id not between", value1, value2, "storeAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdIsNull() {
addCriterion("out_account_id is null");
return (Criteria) this;
}
public Criteria andOutAccountIdIsNotNull() {
addCriterion("out_account_id is not null");
return (Criteria) this;
}
public Criteria andOutAccountIdEqualTo(Integer value) {
addCriterion("out_account_id =", value, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdNotEqualTo(Integer value) {
addCriterion("out_account_id <>", value, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdGreaterThan(Integer value) {
addCriterion("out_account_id >", value, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdGreaterThanOrEqualTo(Integer value) {
addCriterion("out_account_id >=", value, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdLessThan(Integer value) {
addCriterion("out_account_id <", value, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdLessThanOrEqualTo(Integer value) {
addCriterion("out_account_id <=", value, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdIn(List<Integer> values) {
addCriterion("out_account_id in", values, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdNotIn(List<Integer> values) {
addCriterion("out_account_id not in", values, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdBetween(Integer value1, Integer value2) {
addCriterion("out_account_id between", value1, value2, "outAccountId");
return (Criteria) this;
}
public Criteria andOutAccountIdNotBetween(Integer value1, Integer value2) {
addCriterion("out_account_id not between", value1, value2, "outAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdIsNull() {
addCriterion("finance_account_id is null");
return (Criteria) this;
}
public Criteria andFinanceAccountIdIsNotNull() {
addCriterion("finance_account_id is not null");
return (Criteria) this;
}
public Criteria andFinanceAccountIdEqualTo(Integer value) {
addCriterion("finance_account_id =", value, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdNotEqualTo(Integer value) {
addCriterion("finance_account_id <>", value, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdGreaterThan(Integer value) {
addCriterion("finance_account_id >", value, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdGreaterThanOrEqualTo(Integer value) {
addCriterion("finance_account_id >=", value, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdLessThan(Integer value) {
addCriterion("finance_account_id <", value, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdLessThanOrEqualTo(Integer value) {
addCriterion("finance_account_id <=", value, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdIn(List<Integer> values) {
addCriterion("finance_account_id in", values, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdNotIn(List<Integer> values) {
addCriterion("finance_account_id not in", values, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdBetween(Integer value1, Integer value2) {
addCriterion("finance_account_id between", value1, value2, "financeAccountId");
return (Criteria) this;
}
public Criteria andFinanceAccountIdNotBetween(Integer value1, Integer value2) {
addCriterion("finance_account_id not between", value1, value2, "financeAccountId");
return (Criteria) this;
}
public Criteria andPayTypeIsNull() {
addCriterion("pay_type is null");
return (Criteria) this;
}
public Criteria andPayTypeIsNotNull() {
addCriterion("pay_type is not null");
return (Criteria) this;
}
public Criteria andPayTypeEqualTo(String value) {
addCriterion("pay_type =", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeNotEqualTo(String value) {
addCriterion("pay_type <>", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeGreaterThan(String value) {
addCriterion("pay_type >", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeGreaterThanOrEqualTo(String value) {
addCriterion("pay_type >=", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeLessThan(String value) {
addCriterion("pay_type <", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeLessThanOrEqualTo(String value) {
addCriterion("pay_type <=", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeLike(String value) {
addCriterion("pay_type like", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeNotLike(String value) {
addCriterion("pay_type not like", value, "payType");
return (Criteria) this;
}
public Criteria andPayTypeIn(List<String> values) {
addCriterion("pay_type in", values, "payType");
return (Criteria) this;
}
public Criteria andPayTypeNotIn(List<String> values) {
addCriterion("pay_type not in", values, "payType");
return (Criteria) this;
}
public Criteria andPayTypeBetween(String value1, String value2) {
addCriterion("pay_type between", value1, value2, "payType");
return (Criteria) this;
}
public Criteria andPayTypeNotBetween(String value1, String value2) {
addCriterion("pay_type not between", value1, value2, "payType");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | [
"wqwking@126.com"
] | wqwking@126.com |
1203f422097932494b49ba125319cff6727d45a6 | 249c525aeb13eef0b6d468dc2fcef5f36ac1ae1e | /WEB-INF/classes/UpdateEmp.java | d231ee0733870948f493d675f4e5f45d48bccbda | [] | no_license | srlogs/Employee.manage | 93a7bc189d84a1d3e06c4745bd20e5266d4cf9ff | 4e7f7ae946f6456f8431d574c0778461748ad6a1 | refs/heads/master | 2022-03-01T08:06:22.697383 | 2019-11-04T07:04:57 | 2019-11-04T07:04:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,174 | java | import java.io.*;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import javax.servlet.*;
import javax.servlet.http.*;
import EmployeeManagement.*;
import org.json.JSONObject;
import org.json.JSONArray;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
public class UpdateEmp extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
PrintWriter pw = response.getWriter();
ServletContext sc = this.getServletContext();
Connection con = null;
Statement stmt = null;
try
{
HttpSession session = request.getSession();
String name = request.getParameter("name");
String phone = request.getParameter("phone_number");
String address = request.getParameter("address");
String regid = request.getParameter("registrationid");
String bg = request.getParameter("Blood");
String dob = request.getParameter("dob");
String fn = request.getParameter("fatherName");
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/employee","postgres","password");
DatabaseMetaData dbm = con.getMetaData();
ResultSet rs = dbm.getTables(null, null, "company", null);
if(rs.next())
{
stmt = con.createStatement();
if(phone != null && address != null && regid != null && bg != null && fn != null)
{
String upd = "UPDATE company SET Name = '"+name+"', Phone = '"+phone+"', RegisterNum = '"+regid+"', DateofBirth = '"+dob+"', FatherName = '"+fn+"', BloodGroup = '"+bg+"', Address = '"+address+"' WHERE company.Id ='"+session.getAttribute("id")+"'";
stmt.executeUpdate(upd);
}
}
stmt.close();
con.close();
RequestDispatcher rd = sc.getRequestDispatcher("/welcomePage.jsp");
rd.include(request, response);
}
catch(Exception e)
{
pw.println(e);
}
}
}
| [
"logeshwaran.sr1@gmail.com"
] | logeshwaran.sr1@gmail.com |
a11970af562b57865138ca8ea3f765fbefb84779 | e2b8fe089609770121bc1115dc458e5541bc849f | /src/main/java/net/mffjam2/common/block/GemInfuserBlock.java | e0832bc83d382f5c2b0b9527acc039697ed00e4f | [
"Apache-2.0"
] | permissive | Maaxed/MFFJam2 | 8ed8bbf13878fc320e6b5628361c8ed053f912a6 | 27eb75a11021ec733328065b46f89426bfe1df5a | refs/heads/master | 2022-07-06T15:44:13.848632 | 2020-05-03T22:00:40 | 2020-05-03T22:00:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,088 | java | package net.mffjam2.common.block;
import javax.annotation.Nullable;
import net.mffjam2.common.tile.GemInfuserTile;
import net.mffjam2.setup.JamTiles;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.CapabilityItemHandler;
public class GemInfuserBlock extends Block
{
public GemInfuserBlock(Properties properties)
{
super(properties);
}
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
@Override
@Nullable
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return JamTiles.GEM_INFUSER.create();
}
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
{
if (state.getBlock() != newState.getBlock())
{
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof GemInfuserTile)
{
te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(itemHandler ->
{
for (int i = 0; i < itemHandler.getSlots(); i++)
{
InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), itemHandler.getStackInSlot(i));
}
});
}
worldIn.removeTileEntity(pos);
}
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit)
{
if (worldIn.isRemote)
return true;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof GemInfuserTile)
{
NetworkHooks.openGui((ServerPlayerEntity)player, (GemInfuserTile) tileentity, pos);
}
return true;
}
}
| [
"spb.max2@gmail.com"
] | spb.max2@gmail.com |
9236db66edf6f0f15de8f4d2da638108fc4700ad | 1a21f15803cc8a596e87f5a4b87191abe3d3620f | /src/main/java/com/company/JavaEnum/LegacyCalculator.java | f44cdd0881e76b669879b9b6c190dc63ab605c2e | [] | no_license | kunhong/java8_demo | c0bad6e67184e32f791831ae399810090afad303 | b865426cedc28977755e0f2a78445d771c447db2 | refs/heads/master | 2022-12-23T06:26:30.723452 | 2019-07-10T10:30:48 | 2019-07-10T10:30:48 | 126,169,966 | 0 | 0 | null | 2022-12-10T05:15:38 | 2018-03-21T11:40:32 | Java | UTF-8 | Java | false | false | 586 | java | package com.company.JavaEnum;
public class LegacyCalculator {
public static void main(String[] args) {
CalculatorType codeA = CalculatorType.CAL_A;
CalculatorType codeB = CalculatorType.CAL_B;
CalculatorType codeC = CalculatorType.CAL_C;
CalculatorType codeETC = CalculatorType.CAL_ETC;
System.out.println("codeA : " + codeA.calculate(10));
System.out.println("codeB : " + codeB.calculate(10));
System.out.println("codeC : " + codeC.calculate(10));
System.out.println("codeETC : " + codeETC.calculate(10));
}
}
| [
"chingu100@gmail.com"
] | chingu100@gmail.com |
fa83fe9eb4931208fded4fe3ae586d29ae01ea06 | 042f3cca8cd63812f9eb766c98fc0465373687b4 | /source_code/msc.android.jacroid.diagram/src/jacroidEMF/diagram/part/JacroidEMFDiagramActionBarContributor.java | bc89c5ea5f78a4886d4075bfac71394dca11e044 | [
"MIT"
] | permissive | willamys/msc.android.jacroid | 7ba5dd8a386e3712808756b7b7ad57832cef0fd5 | 7123efdbfaf9adae2cc33f02af2738e643d83a4b | refs/heads/master | 2018-09-17T22:03:39.383689 | 2018-08-09T16:58:35 | 2018-08-09T16:58:35 | 110,471,817 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,792 | java | /*
*
*/
package jacroidEMF.diagram.part;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramActionBarContributor;
import org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.EnhancedPrintActionHelper;
import org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.RenderedPrintPreviewAction;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
/**
* @generated
*/
public class JacroidEMFDiagramActionBarContributor extends
DiagramActionBarContributor {
/**
* @generated
*/
protected Class getEditorClass() {
return jacroidEMF.diagram.part.JacroidEMFDiagramEditor.class;
}
/**
* @generated
*/
protected String getEditorId() {
return jacroidEMF.diagram.part.JacroidEMFDiagramEditor.ID;
}
/**
* @generated
*/
public void init(IActionBars bars, IWorkbenchPage page) {
super.init(bars, page);
// print preview
IMenuManager fileMenu = bars.getMenuManager().findMenuUsingPath(
IWorkbenchActionConstants.M_FILE);
assert fileMenu != null;
IAction printPreviewAction = new RenderedPrintPreviewAction(
new EnhancedPrintActionHelper());
fileMenu.insertBefore("print", printPreviewAction); //$NON-NLS-1$
IMenuManager editMenu = bars.getMenuManager().findMenuUsingPath(
IWorkbenchActionConstants.M_EDIT);
assert editMenu != null;
if (editMenu.find("validationGroup") == null) { //$NON-NLS-1$
editMenu.add(new GroupMarker("validationGroup")); //$NON-NLS-1$
}
IAction validateAction = new jacroidEMF.diagram.part.ValidateAction(
page);
editMenu.appendToGroup("validationGroup", validateAction); //$NON-NLS-1$
}
}
| [
"willamysaraujo7@gmail.com"
] | willamysaraujo7@gmail.com |
3346c674135443adef659c36b6d8cf708345be05 | 2b15b54d983296454ec76069cca71591400570ea | /src/com/Collection/java/hashset2.java | 75967ec4ed8e57bfdf5081618581365134845f52 | [] | no_license | dhruv26rathore/java-collections-hashset | d0b820e435088c2896847a46b14797ca20a24bed | 5a5973a06475184dcdcd07adeac7bfb6323a456e | refs/heads/master | 2022-12-19T23:50:22.646891 | 2020-09-19T04:07:35 | 2020-09-19T04:07:35 | 296,783,421 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 607 | java | package com.Collection.java;
import java.util.HashSet;
import java.util.Iterator;
//iterate the elements from hashset
public class hashset2 {
public static void main(String[]args){
HashSet<String> hash_set = new HashSet<String>();
hash_set.add("Rahul");
hash_set.add("Dhruv");
hash_set.add("Sumit");
hash_set.add("Amit");
hash_set.add("Aayush");
hash_set.add("Nilesh");
System.out.println(hash_set);
Iterator<String> p = hash_set.iterator();
while (p.hasNext()){
System.out.println(p.next());
}
}
}
| [
"rmaru470@gmail.com"
] | rmaru470@gmail.com |
50e0f6f13f5067ae587c6904f4c2c76ce0ae095f | 47141b48d29c049a7f4b81721c9754771bacd72e | /app/src/main/java/com/chakam/kampunganggrek/LoginActivity.java | dbb4138b212844b981c574465f9949d60c2cdded | [] | no_license | abdulchakam/Mobile-ECommerce-Kampung-Anggrek | 0c35354659d6585821026aecd067a028de7c1ca6 | cd72ea8326a0edc90b14a8b15e543bfdf01138e0 | refs/heads/master | 2022-11-12T03:08:25.358158 | 2020-06-30T20:20:08 | 2020-06-30T20:20:08 | 260,657,325 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,508 | java | package com.chakam.kampunganggrek;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.chakam.kampunganggrek.Util.AppController;
import com.chakam.kampunganggrek.Util.ServerApi;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class LoginActivity extends AppCompatActivity {
ProgressDialog pDialog;
Button btn_register, btn_login;
EditText txt_email, txt_password;
Intent intent;
int success;
ConnectivityManager conMgr;
private static final String TAG = LoginActivity.class.getSimpleName();
private static final String TAG_SUCCESS = "success";
private static final String TAG_MESSAGE = "message";
public final static String TAG_EMAIL = "email";
public final static String TAG_NAMA_KONS = "nm_kons";
public final static String TAG_KODE_KONS = "kd_kons";
String tag_json_obj = "json_obj_req";
SharedPreferences sharedPreferences;
boolean session = false;
String email, nm_kons, kd_kons;
public static final String my_shared_preferences = "my_sahred_preferences";
public static final String session_status = "session_status";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
TextView to_daftar = (TextView) findViewById(R.id.tv_ToDaftar);
to_daftar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
startActivity(intent);
}
});
conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
{
assert conMgr != null;
if (conMgr.getActiveNetworkInfo() != null &&
conMgr.getActiveNetworkInfo().isAvailable() &&
conMgr.getActiveNetworkInfo().isConnected()) {
} else {
Toast.makeText(getApplicationContext(),
"No Internet Connection", Toast.LENGTH_LONG).show();
}
}
btn_login = (Button) findViewById(R.id.button_login);
//btn_register = (Button) findViewById(R.id.button_signupSignin);
txt_email = (EditText) findViewById(R.id.edt_email);
txt_password = (EditText) findViewById(R.id.edt_pass);
// Cek Session Login jika True maka langsung buka MainActivity
sharedPreferences = getSharedPreferences(my_shared_preferences, Context.MODE_PRIVATE);
session = sharedPreferences.getBoolean(session_status, false);
email = sharedPreferences.getString(TAG_EMAIL, null);
nm_kons = sharedPreferences.getString(TAG_NAMA_KONS, null);
kd_kons = sharedPreferences.getString(TAG_KODE_KONS, null);
if (session) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra(TAG_EMAIL, email);
intent.putExtra(TAG_NAMA_KONS, nm_kons);
intent.putExtra(TAG_KODE_KONS, kd_kons);
startActivity(intent);
finish();
}
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = txt_email.getText().toString();
String password = txt_password.getText().toString();
// Mengecek kolom yang kosong
if (email.trim().length() > 0 &&
password.trim().length() > 0) {
if (conMgr.getActiveNetworkInfo() != null &&
conMgr.getActiveNetworkInfo().isAvailable() &&
conMgr.getActiveNetworkInfo().isConnected()) {
cekLogin(email, password);
} else {
Toast.makeText(getApplicationContext(),
"No Internet Connection", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getApplicationContext(),
"kolom tidak boleh kosong", Toast.LENGTH_LONG).show();
}
}
});
}
// Method Ceklogin
private void cekLogin ( final String email, final String password){
pDialog = new ProgressDialog(this);
pDialog.setCancelable(false);
pDialog.setMessage("Logging in....");
showDialog();
StringRequest stringRequest = new StringRequest(Request.Method.POST, ServerApi.URL_LOGIN, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e(TAG, "Login Response: " + response);
hideDialog();
try {
JSONObject jsonObject = new JSONObject(response);
success = jsonObject.getInt(TAG_SUCCESS);
//Check For Eror node in json
if (success == 1) {
String email = jsonObject.getString(TAG_EMAIL);
String kd_kons = jsonObject.getString(TAG_KODE_KONS);
Log.e("Successfully Login!", jsonObject.toString());
Toast.makeText(getApplicationContext(),
jsonObject.getString(TAG_MESSAGE), Toast.LENGTH_LONG).show();
//Menyimpan Login Ke Session
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(session_status, true);
editor.putString(TAG_EMAIL, email);
editor.putString(TAG_KODE_KONS, kd_kons);
editor.commit();
//Memanggil MainActivity
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra(TAG_EMAIL, email);
intent.putExtra(TAG_NAMA_KONS, nm_kons);
intent.putExtra(TAG_KODE_KONS, kd_kons);
startActivity(intent);
finish();
} else {
Toast.makeText(getApplicationContext(),
jsonObject.getString(TAG_MESSAGE), Toast.LENGTH_LONG).show();
hideDialog();
pDialog.cancel();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Login Error: " + error.getMessage());
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
hideDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
// Posting parameters to login url
Map<String, String> params = new HashMap<String, String>();
params.put("email", email);
params.put("password", password);
return params;
}
};
AppController.getInstance().addToRequestQueue(stringRequest, tag_json_obj);
}
//Method showDialog
private void showDialog(){
if(!pDialog.isShowing())
pDialog.show();
}
//Method hideDialog
private void hideDialog(){
if(pDialog.isShowing())
pDialog.show();
}
}
| [
"muhammadabdulchakam@gmail.com"
] | muhammadabdulchakam@gmail.com |
4cfd64a1f916d278bd5f71fcecc5cd6c46734d7e | 4ef1b972593f699a71e4eca7ee1010aa231f52cc | /hnLibrary/src/main/java/com/hn/library/utils/HnFileUtils.java | 354eb570bf6c0682a4f2ad1629ac6c54578532b4 | [] | no_license | LoooooG/youyou | e2e8fb0f576a6e2daf614d1186303ec7ce7bdf4a | 5bff0de57159ab3dda075343b83ff4a461df66e2 | refs/heads/master | 2020-12-03T12:52:00.462951 | 2020-02-17T10:29:59 | 2020-02-17T10:29:59 | 231,321,844 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 43,168 | java | package com.hn.library.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.media.ThumbnailUtils;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import static com.hn.library.utils.EncryptUtils.bytes2HexString;
/**
* Copyright (C) 2016,深圳市红鸟网络科技股份有限公司 All rights reserved.
* 项目名称:
* 类描述: 文件相关工具类
* 创建人:Kevin
* 创建时间:2016/5/13 9:43
* 修改人:Kevin
* 修改时间:2016/5/13 9:43
* 修改备注:
* Version: 1.0.0
*/
public class HnFileUtils {
private HnFileUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* 根据文件路径获取文件
*
* @param filePath 文件路径
* @return 文件
*/
public static File getFileByPath(String filePath) {
return (filePath == null || filePath.trim().length() == 0) ? null : new File(filePath);
}
/**
* 判断文件是否存在
*
* @param filePath 文件路径
* @return {@code true}: 存在<br>{@code false}: 不存在
*/
public static boolean isFileExists(String filePath) {
return isFileExists(getFileByPath(filePath));
}
/**
* 判断文件是否存在
*
* @param file 文件
* @return {@code true}: 存在<br>{@code false}: 不存在
*/
public static boolean isFileExists(File file) {
return file != null && file.exists();
}
/**
* 重命名文件
*
* @param filePath 文件路径
* @param newName 新名称
* @return {@code true}: 重命名成功<br>{@code false}: 重命名失败
*/
public static boolean rename(String filePath, String newName) {
return rename(getFileByPath(filePath), newName);
}
/**
* 重命名文件
*
* @param file 文件
* @param newName 新名称
* @return {@code true}: 重命名成功<br>{@code false}: 重命名失败
*/
public static boolean rename(File file, String newName) {
// 文件为空返回false
if (file == null) return false;
// 文件不存在返回false
if (!file.exists()) return false;
// 新的文件名为空返回false
if ( TextUtils.isEmpty(newName)) return false;
// 如果文件名没有改变返回true
if (newName.equals(file.getName())) return true;
File newFile = new File(file.getParent() + File.separator + newName);
// 如果重命名的文件已存在返回false
return !newFile.exists()
&& file.renameTo(newFile);
}
/**
* 判断是否是目录
*
* @param dirPath 目录路径
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isDir(String dirPath) {
return isDir(getFileByPath(dirPath));
}
/**
* 判断是否是目录
*
* @param file 文件
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isDir(File file) {
return isFileExists(file) && file.isDirectory();
}
/**
* 判断是否是文件
*
* @param filePath 文件路径
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isFile(String filePath) {
return isFile(getFileByPath(filePath));
}
/**
* 判断是否是文件
*
* @param file 文件
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isFile(File file) {
return isFileExists(file) && file.isFile();
}
/**
* 判断目录是否存在,不存在则判断是否创建成功
*
* @param dirPath 目录路径
* @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
*/
public static boolean createOrExistsDir(String dirPath) {
return createOrExistsDir(getFileByPath(dirPath));
}
/**
* 判断目录是否存在,不存在则判断是否创建成功
*
* @param file 文件
* @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
*/
public static boolean createOrExistsDir(File file) {
// 如果存在,是目录则返回true,是文件则返回false,不存在则返回是否创建成功
return file != null && (file.exists() ? file.isDirectory() : file.mkdirs());
}
/**
* 判断文件是否存在,不存在则判断是否创建成功
*
* @param filePath 文件路径
* @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
*/
public static boolean createOrExistsFile(String filePath) {
return createOrExistsFile(getFileByPath(filePath));
}
/**
* 判断文件是否存在,不存在则判断是否创建成功
*
* @param file 文件
* @return {@code true}: 存在或创建成功<br>{@code false}: 不存在或创建失败
*/
public static boolean createOrExistsFile(File file) {
if (file == null) return false;
// 如果存在,是文件则返回true,是目录则返回false
if (file.exists()) return file.isFile();
if (!createOrExistsDir(file.getParentFile())) return false;
try {
return file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
/**
* 判断文件是否存在,存在则在创建之前删除
*
* @param filePath 文件路径
* @return {@code true}: 创建成功<br>{@code false}: 创建失败
*/
public static boolean createFileByDeleteOldFile(String filePath) {
return createFileByDeleteOldFile(getFileByPath(filePath));
}
/**
* 判断文件是否存在,存在则在创建之前删除
*
* @param file 文件
* @return {@code true}: 创建成功<br>{@code false}: 创建失败
*/
public static boolean createFileByDeleteOldFile(File file) {
if (file == null) return false;
// 文件存在并且删除失败返回false
if (file.exists() && file.isFile() && !file.delete()) return false;
// 创建目录失败返回false
if (!createOrExistsDir(file.getParentFile())) return false;
try {
return file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
/**
* 复制或移动目录
*
* @param srcDirPath 源目录路径
* @param destDirPath 目标目录路径
* @param isMove 是否移动
* @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
*/
private static boolean copyOrMoveDir(String srcDirPath, String destDirPath, boolean isMove) {
return copyOrMoveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath), isMove);
}
/**
* 复制或移动目录
*
* @param srcDir 源目录
* @param destDir 目标目录
* @param isMove 是否移动
* @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
*/
private static boolean copyOrMoveDir(File srcDir, File destDir, boolean isMove) {
if (srcDir == null || destDir == null) return false;
// 如果目标目录在源目录中则返回false,看不懂的话好好想想递归怎么结束
// srcPath : F:\\MyGithub\\AndroidUtilCode\\utilcode\\src\\test\\res
// destPath: F:\\MyGithub\\AndroidUtilCode\\utilcode\\src\\test\\res1
// 为防止以上这种情况出现出现误判,须分别在后面加个路径分隔符
String srcPath = srcDir.getPath() + File.separator;
String destPath = destDir.getPath() + File.separator;
if (destPath.contains(srcPath)) return false;
// 源文件不存在或者不是目录则返回false
if (!srcDir.exists() || !srcDir.isDirectory()) return false;
// 目标目录不存在返回false
if (!createOrExistsDir(destDir)) return false;
File[] files = srcDir.listFiles();
for (File file : files) {
File oneDestFile = new File(destPath + file.getName());
if (file.isFile()) {
// 如果操作失败返回false
if (!copyOrMoveFile(file, oneDestFile, isMove)) return false;
} else if (file.isDirectory()) {
// 如果操作失败返回false
if (!copyOrMoveDir(file, oneDestFile, isMove)) return false;
}
}
return !isMove || deleteDir(srcDir);
}
/**
* 复制或移动文件
*
* @param srcFilePath 源文件路径
* @param destFilePath 目标文件路径
* @param isMove 是否移动
* @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
*/
private static boolean copyOrMoveFile(String srcFilePath, String destFilePath, boolean isMove) {
return copyOrMoveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath), isMove);
}
/**
* 复制或移动文件
*
* @param srcFile 源文件
* @param destFile 目标文件
* @param isMove 是否移动
* @return {@code true}: 复制或移动成功<br>{@code false}: 复制或移动失败
*/
private static boolean copyOrMoveFile(File srcFile, File destFile, boolean isMove) {
if (srcFile == null || destFile == null) return false;
// 源文件不存在或者不是文件则返回false
if (!srcFile.exists() || !srcFile.isFile()) return false;
// 目标文件存在且是文件则返回false
if (destFile.exists() && destFile.isFile()) return false;
// 目标目录不存在返回false
if (!createOrExistsDir(destFile.getParentFile())) return false;
try {
return writeFileFromIS(destFile, new FileInputStream(srcFile), false)
&& !(isMove && !deleteFile(srcFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
}
}
/**
* 复制目录
*
* @param srcDirPath 源目录路径
* @param destDirPath 目标目录路径
* @return {@code true}: 复制成功<br>{@code false}: 复制失败
*/
public static boolean copyDir(String srcDirPath, String destDirPath) {
return copyDir(getFileByPath(srcDirPath), getFileByPath(destDirPath));
}
/**
* 复制目录
*
* @param srcDir 源目录
* @param destDir 目标目录
* @return {@code true}: 复制成功<br>{@code false}: 复制失败
*/
public static boolean copyDir(File srcDir, File destDir) {
return copyOrMoveDir(srcDir, destDir, false);
}
/**
* 复制文件
*
* @param srcFilePath 源文件路径
* @param destFilePath 目标文件路径
* @return {@code true}: 复制成功<br>{@code false}: 复制失败
*/
public static boolean copyFile(String srcFilePath, String destFilePath) {
return copyFile(getFileByPath(srcFilePath), getFileByPath(destFilePath));
}
/**
* 复制文件
*
* @param srcFile 源文件
* @param destFile 目标文件
* @return {@code true}: 复制成功<br>{@code false}: 复制失败
*/
public static boolean copyFile(File srcFile, File destFile) {
return copyOrMoveFile(srcFile, destFile, false);
}
/**
* 移动目录
*
* @param srcDirPath 源目录路径
* @param destDirPath 目标目录路径
* @return {@code true}: 移动成功<br>{@code false}: 移动失败
*/
public static boolean moveDir(String srcDirPath, String destDirPath) {
return moveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath));
}
/**
* 移动目录
*
* @param srcDir 源目录
* @param destDir 目标目录
* @return {@code true}: 移动成功<br>{@code false}: 移动失败
*/
public static boolean moveDir(File srcDir, File destDir) {
return copyOrMoveDir(srcDir, destDir, true);
}
/**
* 移动文件
*
* @param srcFilePath 源文件路径
* @param destFilePath 目标文件路径
* @return {@code true}: 移动成功<br>{@code false}: 移动失败
*/
public static boolean moveFile(String srcFilePath, String destFilePath) {
return moveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath));
}
/**
* 移动文件
*
* @param srcFile 源文件
* @param destFile 目标文件
* @return {@code true}: 移动成功<br>{@code false}: 移动失败
*/
public static boolean moveFile(File srcFile, File destFile) {
return copyOrMoveFile(srcFile, destFile, true);
}
/**
* 删除目录
*
* @param dirPath 目录路径
* @return {@code true}: 删除成功<br>{@code false}: 删除失败
*/
public static boolean deleteDir(String dirPath) {
return deleteDir(getFileByPath(dirPath));
}
/**
* 删除目录
*
* @param dir 目录
* @return {@code true}: 删除成功<br>{@code false}: 删除失败
*/
public static boolean deleteDir(File dir) {
if (dir == null) return false;
// 目录不存在返回true
if (!dir.exists()) return true;
// 不是目录返回false
if (!dir.isDirectory()) return false;
// 现在文件存在且是文件夹
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (file.isFile()) {
if (!deleteFile(file)) return false;
} else if (file.isDirectory()) {
if (!deleteDir(file)) return false;
}
}
}
return dir.delete();
}
/**
* 删除文件
*
* @param srcFilePath 文件路径
* @return {@code true}: 删除成功<br>{@code false}: 删除失败
*/
public static boolean deleteFile(String srcFilePath) {
return deleteFile(getFileByPath(srcFilePath));
}
/**
* 删除文件
*
* @param file 文件
* @return {@code true}: 删除成功<br>{@code false}: 删除失败
*/
public static boolean deleteFile(File file) {
return file != null && (!file.exists() || file.isFile() && file.delete());
}
/**
* 删除目录下的所有文件
*
* @param dirPath 目录路径
* @return {@code true}: 删除成功<br>{@code false}: 删除失败
*/
public static boolean deleteFilesInDir(String dirPath) {
return deleteFilesInDir(getFileByPath(dirPath));
}
/**
* 删除目录下的所有文件
*
* @param dir 目录
* @return {@code true}: 删除成功<br>{@code false}: 删除失败
*/
public static boolean deleteFilesInDir(File dir) {
if (dir == null) return false;
// 目录不存在返回true
if (!dir.exists()) return true;
// 不是目录返回false
if (!dir.isDirectory()) return false;
// 现在文件存在且是文件夹
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (file.isFile()) {
if (!deleteFile(file)) return false;
} else if (file.isDirectory()) {
if (!deleteDir(file)) return false;
}
}
}
return true;
}
/**
* 获取目录下所有文件
*
* @param dirPath 目录路径
* @param isRecursive 是否递归进子目录
* @return 文件链表
*/
public static List<File> listFilesInDir(String dirPath, boolean isRecursive) {
return listFilesInDir(getFileByPath(dirPath), isRecursive);
}
/**
* 获取目录下所有文件
*
* @param dir 目录
* @param isRecursive 是否递归进子目录
* @return 文件链表
*/
public static List<File> listFilesInDir(File dir, boolean isRecursive) {
if (!isDir(dir)) return null;
if (isRecursive) return listFilesInDir(dir);
List<File> list = new ArrayList<>();
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
Collections.addAll(list, files);
}
return list;
}
/**
* 获取目录下所有文件包括子目录
*
* @param dirPath 目录路径
* @return 文件链表
*/
public static List<File> listFilesInDir(String dirPath) {
return listFilesInDir(getFileByPath(dirPath));
}
/**
* 获取目录下所有文件包括子目录
*
* @param dir 目录
* @return 文件链表
*/
public static List<File> listFilesInDir(File dir) {
if (!isDir(dir)) return null;
List<File> list = new ArrayList<>();
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
list.add(file);
if (file.isDirectory()) {
list.addAll(listFilesInDir(file));
}
}
}
return list;
}
/**
* 获取目录下所有后缀名为suffix的文件
* <p>大小写忽略</p>
*
* @param dirPath 目录路径
* @param suffix 后缀名
* @param isRecursive 是否递归进子目录
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(String dirPath, String suffix, boolean isRecursive) {
return listFilesInDirWithFilter(getFileByPath(dirPath), suffix, isRecursive);
}
/**
* 获取目录下所有后缀名为suffix的文件
* <p>大小写忽略</p>
*
* @param dir 目录
* @param suffix 后缀名
* @param isRecursive 是否递归进子目录
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(File dir, String suffix, boolean isRecursive) {
if (isRecursive) return listFilesInDirWithFilter(dir, suffix);
if (dir == null || !isDir(dir)) return null;
List<File> list = new ArrayList<>();
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (file.getName().toUpperCase().endsWith(suffix.toUpperCase())) {
list.add(file);
}
}
}
return list;
}
/**
* 获取目录下所有后缀名为suffix的文件包括子目录
* <p>大小写忽略</p>
*
* @param dirPath 目录路径
* @param suffix 后缀名
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(String dirPath, String suffix) {
return listFilesInDirWithFilter(getFileByPath(dirPath), suffix);
}
/**
* 获取目录下所有后缀名为suffix的文件包括子目录
* <p>大小写忽略</p>
*
* @param dir 目录
* @param suffix 后缀名
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(File dir, String suffix) {
if (dir == null || !isDir(dir)) return null;
List<File> list = new ArrayList<>();
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (file.getName().toUpperCase().endsWith(suffix.toUpperCase())) {
list.add(file);
}
if (file.isDirectory()) {
list.addAll(listFilesInDirWithFilter(file, suffix));
}
}
}
return list;
}
/**
* 获取目录下所有符合filter的文件
*
* @param dirPath 目录路径
* @param filter 过滤器
* @param isRecursive 是否递归进子目录
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(String dirPath, FilenameFilter filter, boolean isRecursive) {
return listFilesInDirWithFilter(getFileByPath(dirPath), filter, isRecursive);
}
/**
* 获取目录下所有符合filter的文件
*
* @param dir 目录
* @param filter 过滤器
* @param isRecursive 是否递归进子目录
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(File dir, FilenameFilter filter, boolean isRecursive) {
if (isRecursive) return listFilesInDirWithFilter(dir, filter);
if (dir == null || !isDir(dir)) return null;
List<File> list = new ArrayList<>();
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (filter.accept(file.getParentFile(), file.getName())) {
list.add(file);
}
}
}
return list;
}
/**
* 获取目录下所有符合filter的文件包括子目录
*
* @param dirPath 目录路径
* @param filter 过滤器
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(String dirPath, FilenameFilter filter) {
return listFilesInDirWithFilter(getFileByPath(dirPath), filter);
}
/**
* 获取目录下所有符合filter的文件包括子目录
*
* @param dir 目录
* @param filter 过滤器
* @return 文件链表
*/
public static List<File> listFilesInDirWithFilter(File dir, FilenameFilter filter) {
if (dir == null || !isDir(dir)) return null;
List<File> list = new ArrayList<>();
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (filter.accept(file.getParentFile(), file.getName())) {
list.add(file);
}
if (file.isDirectory()) {
list.addAll(listFilesInDirWithFilter(file, filter));
}
}
}
return list;
}
/**
* 获取目录下指定文件名的文件包括子目录
* <p>大小写忽略</p>
*
* @param dirPath 目录路径
* @param fileName 文件名
* @return 文件链表
*/
public static List<File> searchFileInDir(String dirPath, String fileName) {
return searchFileInDir(getFileByPath(dirPath), fileName);
}
/**
* 获取目录下指定文件名的文件包括子目录
* <p>大小写忽略</p>
*
* @param dir 目录
* @param fileName 文件名
* @return 文件链表
*/
public static List<File> searchFileInDir(File dir, String fileName) {
if (dir == null || !isDir(dir)) return null;
List<File> list = new ArrayList<>();
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (file.getName().toUpperCase().equals(fileName.toUpperCase())) {
list.add(file);
}
if (file.isDirectory()) {
list.addAll(searchFileInDir(file, fileName));
}
}
}
return list;
}
/**
* 将输入流写入文件
*
* @param filePath 路径
* @param is 输入流
* @param append 是否追加在文件末
* @return {@code true}: 写入成功<br>{@code false}: 写入失败
*/
public static boolean writeFileFromIS(String filePath, InputStream is, boolean append) {
return writeFileFromIS(getFileByPath(filePath), is, append);
}
/**
* 将输入流写入文件
*
* @param file 文件
* @param is 输入流
* @param append 是否追加在文件末
* @return {@code true}: 写入成功<br>{@code false}: 写入失败
*/
public static boolean writeFileFromIS(File file, InputStream is, boolean append) {
if (file == null || is == null) return false;
if (!createOrExistsFile(file)) return false;
OutputStream os = null;
try {
os = new BufferedOutputStream(new FileOutputStream(file, append));
byte data[] = new byte[1024];
int len;
while ((len = is.read(data, 0, 1024)) != -1) {
os.write(data, 0, len);
}
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
closeIO(is, os);
}
}
/**
* 关闭IO
*
* @param closeables closeable
*/
public static void closeIO(Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 将字符串写入文件
*
* @param filePath 文件路径
* @param content 写入内容
* @param append 是否追加在文件末
* @return {@code true}: 写入成功<br>{@code false}: 写入失败
*/
public static boolean writeFileFromString(String filePath, String content, boolean append) {
return writeFileFromString(getFileByPath(filePath), content, append);
}
/**
* 将字符串写入文件
*
* @param file 文件
* @param content 写入内容
* @param append 是否追加在文件末
* @return {@code true}: 写入成功<br>{@code false}: 写入失败
*/
public static boolean writeFileFromString(File file, String content, boolean append) {
if (file == null || content == null) return false;
if (!createOrExistsFile(file)) return false;
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(file, append));
bw.write(content);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
closeIO(bw);
}
}
/**
* 指定编码按行读取文件到链表中
*
* @param filePath 文件路径
* @param charsetName 编码格式
* @return 文件行链表
*/
public static List<String> readFile2List(String filePath, String charsetName) {
return readFile2List(getFileByPath(filePath), charsetName);
}
/**
* 指定编码按行读取文件到链表中
*
* @param file 文件
* @param charsetName 编码格式
* @return 文件行链表
*/
public static List<String> readFile2List(File file, String charsetName) {
return readFile2List(file, 0, 0x7FFFFFFF, charsetName);
}
/**
* 指定编码按行读取文件到链表中
*
* @param filePath 文件路径
* @param st 需要读取的开始行数
* @param end 需要读取的结束行数
* @param charsetName 编码格式
* @return 包含制定行的list
*/
public static List<String> readFile2List(String filePath, int st, int end, String
charsetName) {
return readFile2List(getFileByPath(filePath), st, end, charsetName);
}
/**
* 指定编码按行读取文件到链表中
*
* @param file 文件
* @param st 需要读取的开始行数
* @param end 需要读取的结束行数
* @param charsetName 编码格式
* @return 包含从start行到end行的list
*/
public static List<String> readFile2List(File file, int st, int end, String charsetName) {
if (file == null) return null;
if (st > end) return null;
BufferedReader reader = null;
try {
String line;
int curLine = 1;
List<String> list = new ArrayList<>();
if ( TextUtils.isEmpty(charsetName)) {
reader = new BufferedReader(new FileReader(file));
} else {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
}
while ((line = reader.readLine()) != null) {
if (curLine > end) break;
if (st <= curLine && curLine <= end) list.add(line);
++curLine;
}
return list;
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
closeIO(reader);
}
}
/**
* 指定编码按行读取文件到字符串中
*
* @param filePath 文件路径
* @param charsetName 编码格式
* @return 字符串
*/
public static String readFile2String(String filePath, String charsetName) {
return readFile2String(getFileByPath(filePath), charsetName);
}
/**
* 指定编码按行读取文件到字符串中
*
* @param file 文件
* @param charsetName 编码格式
* @return 字符串
*/
public static String readFile2String(File file, String charsetName) {
if (file == null) return null;
BufferedReader reader = null;
try {
StringBuilder sb = new StringBuilder();
if ( TextUtils.isEmpty(charsetName)) {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
} else {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
}
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\r\n");// windows系统换行为\r\n,Linux为\n
}
// 要去除最后的换行符
return sb.delete(sb.length() - 2, sb.length()).toString();
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
closeIO(reader);
}
}
/**
* 获取文件最后修改的毫秒时间戳
*
* @param filePath 文件路径
* @return 文件最后修改的毫秒时间戳
*/
public static long getFileLastModified(String filePath) {
return getFileLastModified(getFileByPath(filePath));
}
/**
* 获取文件最后修改的毫秒时间戳
*
* @param file 文件
* @return 文件最后修改的毫秒时间戳
*/
public static long getFileLastModified(File file) {
if (file == null) return -1;
return file.lastModified();
}
/**
* 简单获取文件编码格式
*
* @param filePath 文件路径
* @return 文件编码
*/
public static String getFileCharsetSimple(String filePath) {
return getFileCharsetSimple(getFileByPath(filePath));
}
/**
* 简单获取文件编码格式
*
* @param file 文件
* @return 文件编码
*/
public static String getFileCharsetSimple(File file) {
int p = 0;
InputStream is = null;
try {
is = new BufferedInputStream(new FileInputStream(file));
p = (is.read() << 8) + is.read();
} catch (IOException e) {
e.printStackTrace();
} finally {
closeIO(is);
}
switch (p) {
case 0xefbb:
return "UTF-8";
case 0xfffe:
return "Unicode";
case 0xfeff:
return "UTF-16BE";
default:
return "GBK";
}
}
/**
* 获取文件行数
*
* @param filePath 文件路径
* @return 文件行数
*/
public static int getFileLines(String filePath) {
return getFileLines(getFileByPath(filePath));
}
/**
* 获取文件行数
*
* @param file 文件
* @return 文件行数
*/
public static int getFileLines(File file) {
int count = 1;
InputStream is = null;
try {
is = new BufferedInputStream(new FileInputStream(file));
byte[] buffer = new byte[1024];
int readChars;
while ((readChars = is.read(buffer, 0, 1024)) != -1) {
for (int i = 0; i < readChars; ++i) {
if (buffer[i] == '\n') ++count;
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
closeIO(is);
}
return count;
}
/**
/**
* 获取文件大小
*
* @param filePath 文件路径
* @return 文件大小
*/
public static String getFileSize(String filePath) {
return getFileSize(getFileByPath(filePath));
}
/**
* 获取文件大小
*
* @param file 文件
* @return 文件大小
*/
public static String getFileSize(File file) {
long len = getFileLength(file);
return len == -1 ? "" : byte2FitMemorySize(len);
}
/**
* 字节数转合适内存大小
* <p>保留3位小数</p>
*
* @param byteNum 字节数
* @return 合适内存大小
*/
@SuppressLint("DefaultLocale")
public static String byte2FitMemorySize(long byteNum) {
if (byteNum < 0) {
return "shouldn't be less than zero!";
} else if (byteNum < HnConstUtils.KB) {
return String.format("%.3fB", byteNum + 0.0005);
} else if (byteNum < HnConstUtils.MB) {
return String.format("%.3fKB", byteNum / HnConstUtils.KB + 0.0005);
} else if (byteNum < HnConstUtils.GB) {
return String.format("%.3fMB", byteNum / HnConstUtils.MB + 0.0005);
} else {
return String.format("%.3fGB", byteNum / HnConstUtils.GB + 0.0005);
}
}
/**
* 获取目录长度
*
* @param dirPath 目录路径
* @return 文件大小
*/
public static long getDirLength(String dirPath) {
return getDirLength(getFileByPath(dirPath));
}
/**
* 获取目录长度
*
* @param dir 目录
* @return 文件大小
*/
public static long getDirLength(File dir) {
if (!isDir(dir)) return -1;
long len = 0;
File[] files = dir.listFiles();
if (files != null && files.length != 0) {
for (File file : files) {
if (file.isDirectory()) {
len += getDirLength(file);
} else {
len += file.length();
}
}
}
return len;
}
/**
* 获取文件长度
*
* @param filePath 文件路径
* @return 文件大小
*/
public static long getFileLength(String filePath) {
return getFileLength(getFileByPath(filePath));
}
/**
* 获取文件长度
*
* @param file 文件
* @return 文件大小
*/
public static long getFileLength(File file) {
if (!isFile(file)) return -1;
return file.length();
}
/**
* 获取文件的MD5校验码
*
* @param filePath 文件路径
* @return 文件的MD5校验码
*/
public static String getFileMD5ToString(String filePath) {
File file = TextUtils.isEmpty(filePath) ? null : new File(filePath);
return getFileMD5ToString(file);
}
/**
* 获取文件的MD5校验码
*
* @param filePath 文件路径
* @return 文件的MD5校验码
*/
public static byte[] getFileMD5(String filePath) {
File file = TextUtils.isEmpty(filePath) ? null : new File(filePath);
return getFileMD5(file);
}
/**
* 获取文件的MD5校验码
*
* @param file 文件
* @return 文件的MD5校验码
*/
public static String getFileMD5ToString(File file) {
return bytes2HexString(getFileMD5(file));
}
/**
* 获取文件的MD5校验码
*
* @param file 文件
* @return 文件的MD5校验码
*/
public static byte[] getFileMD5(File file) {
if (file == null) return null;
DigestInputStream dis = null;
try {
FileInputStream fis = new FileInputStream(file);
MessageDigest md = MessageDigest.getInstance("MD5");
dis = new DigestInputStream(fis, md);
byte[] buffer = new byte[1024 * 256];
while (dis.read(buffer) > 0) ;
md = dis.getMessageDigest();
return md.digest();
} catch (NoSuchAlgorithmException | IOException e) {
e.printStackTrace();
} finally {
closeIO(dis);
}
return null;
}
/**
* 获取全路径中的最长目录
*
* @param file 文件
* @return filePath最长目录
*/
public static String getDirName(File file) {
if (file == null) return null;
return getDirName(file.getPath());
}
/**
* 获取全路径中的最长目录
*
* @param filePath 文件路径
* @return filePath最长目录
*/
public static String getDirName(String filePath) {
if ( TextUtils.isEmpty(filePath)) return filePath;
int lastSep = filePath.lastIndexOf(File.separator);
return lastSep == -1 ? "" : filePath.substring(0, lastSep + 1);
}
/**
* 获取全路径中的文件名
*
* @param file 文件
* @return 文件名
*/
public static String getFileName(File file) {
if (file == null) return null;
return getFileName(file.getPath());
}
/**
* 获取全路径中的文件名
*
* @param filePath 文件路径
* @return 文件名
*/
public static String getFileName(String filePath) {
if ( TextUtils.isEmpty(filePath)) return filePath;
int lastSep = filePath.lastIndexOf(File.separator);
return lastSep == -1 ? filePath : filePath.substring(lastSep + 1);
}
/**
* 获取全路径中的不带拓展名的文件名
*
* @param file 文件
* @return 不带拓展名的文件名
*/
public static String getFileNameNoExtension(File file) {
if (file == null) return null;
return getFileNameNoExtension(file.getPath());
}
/**
* 获取全路径中的不带拓展名的文件名
*
* @param filePath 文件路径
* @return 不带拓展名的文件名
*/
public static String getFileNameNoExtension(String filePath) {
if ( TextUtils.isEmpty(filePath)) return filePath;
int lastPoi = filePath.lastIndexOf('.');
int lastSep = filePath.lastIndexOf(File.separator);
if (lastSep == -1) {
return (lastPoi == -1 ? filePath : filePath.substring(0, lastPoi));
}
if (lastPoi == -1 || lastSep > lastPoi) {
return filePath.substring(lastSep + 1);
}
return filePath.substring(lastSep + 1, lastPoi);
}
/**
* 获取全路径中的文件拓展名
*
* @param file 文件
* @return 文件拓展名
*/
public static String getFileExtension(File file) {
if (file == null) return null;
return getFileExtension(file.getPath());
}
/**
* 获取全路径中的文件拓展名
*
* @param filePath 文件路径
* @return 文件拓展名
*/
public static String getFileExtension(String filePath) {
if ( TextUtils.isEmpty(filePath)) return filePath;
int lastPoi = filePath.lastIndexOf('.');
int lastSep = filePath.lastIndexOf(File.separator);
if (lastPoi == -1 || lastSep >= lastPoi) return "";
return filePath.substring(lastPoi + 1);
}
public static File getExternalCacheDir(final Context context) {
if (hasExternalCacheDir())
return context.getExternalCacheDir();
// Before Froyo we need to construct the external cache dir ourselves
final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
return createFile(Environment.getExternalStorageDirectory().getPath() + cacheDir, "");
}
public static boolean hasExternalCacheDir() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
}
public static File createFile(String folderPath, String fileName) {
File destDir = new File(folderPath);
if (!destDir.exists()) {
destDir.mkdirs();
}
return new File(folderPath, fileName);
}
/**
* 获取视频第一针
* @param url
* @param width
* @param height
* @return
*/
public static Bitmap createVideoThumbnail(String url, int width, int height) {
Bitmap bitmap = null;
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
int kind = MediaStore.Video.Thumbnails.MINI_KIND;
try {
if (Build.VERSION.SDK_INT >= 14) {
retriever.setDataSource(url, new HashMap<String, String>());
} else {
retriever.setDataSource(url);
}
bitmap = retriever.getFrameAtTime();
} catch (IllegalArgumentException ex) {
// Assume this is a corrupt video file
} catch (RuntimeException ex) {
// Assume this is a corrupt video file.
} finally {
try {
retriever.release();
} catch (RuntimeException ex) {
// Ignore failures while cleaning up.
}
}
if (kind == MediaStore.Images.Thumbnails.MICRO_KIND && bitmap != null) {
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
}
return bitmap;
}
} | [
"53099003@qq.com"
] | 53099003@qq.com |
fb71334d5bba96ffeb4822f13f1e81b268875051 | 0d5088b29a25cf5169fbc92c2773d5f8f0bafd8e | /Assignment7/src/question3/Tool.java | ed5797372a8504fd32dc083137604de22a445291 | [] | no_license | Jiacheng-Hu/Jiacheng-Hu | df4b42c4b6d2ac32b290b657ba5008f11d0ae4a5 | 14f230f43d49a0f2e2552aa853380bc5d855eed5 | refs/heads/master | 2020-03-28T18:14:57.572320 | 2018-11-17T09:16:04 | 2018-11-17T09:16:04 | 148,862,789 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 172 | java | package question3;
public class Tool {
protected int strength;
protected char type;
public void setStrength(int strength) {
this.strength = strength;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
d76a0a3ccf467d2139464a7fd12aa1b0a6c36b00 | 22b22459a639f3648f21a0092155e24e4cd6d915 | /app/src/main/java/pt/cm/paintapp/MainActivity.java | 78be70c6cf528b662ee6957c559741452fa936eb | [] | no_license | arbsantos/Events_Class | a3ac66ba1a5c0d081d290df7e37ea18534d942a7 | 7990b79fbc579c5b8518c58891b08cdf9e0e2525 | refs/heads/master | 2020-08-30T11:30:58.045392 | 2019-11-06T11:26:47 | 2019-11-06T11:26:47 | 218,366,803 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 840 | java | package pt.cm.paintapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.GestureDetector;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GestureListener mGestureListener = new GestureListener();
GestureDetector mGestureDetector = new GestureDetector(getApplicationContext(), mGestureListener);
mGestureDetector.setIsLongpressEnabled(true);
mGestureDetector.setOnDoubleTapListener(mGestureListener);
PaintCanvas paintCanvas = new PaintCanvas(getApplicationContext(), null, mGestureDetector);
mGestureListener.setCanvas(paintCanvas);
setContentView(paintCanvas);// adds the created view to the screen
}
}
| [
"andre13521@gmail.com"
] | andre13521@gmail.com |
0bfdde5310f6a0befb2f50e60df44000696992a8 | ef6f66d594e33cd2670f5eff6c68c6199202299d | /core/src/main/java/io/token/security/TokenCryptoEngineFactory.java | 4cfae67cdc7179f663585f721cf7f706330c7f58 | [
"MIT"
] | permissive | BartekSzeliga/sdk-java | d927fb0d6f87b64ca561991842db39ec9a0de000 | c0559dc6084339751f03f6d90c7755cedf2820d5 | refs/heads/master | 2023-02-20T13:39:22.439131 | 2021-01-22T16:17:06 | 2021-01-22T16:17:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,308 | java | /**
* Copyright (c) 2020 Token, Inc.
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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 io.token.security;
import static io.token.security.TokenCryptoEngine.DEFAULT_CRYPTO_TYPE;
import io.token.security.crypto.CryptoType;
/**
* Creates {@link CryptoEngine} instances bound to a given member id.
* Uses a provided key store to persist keys.
*/
public class TokenCryptoEngineFactory implements CryptoEngineFactory {
private final KeyStore keyStore;
private final CryptoType cryptoType;
/**
* Creates a new instance of the factory that uses supplied store
* to persist the keys.
*
* @param keyStore key store
*/
public TokenCryptoEngineFactory(KeyStore keyStore) {
this.keyStore = keyStore;
this.cryptoType = DEFAULT_CRYPTO_TYPE;
}
public TokenCryptoEngineFactory(KeyStore keyStore, CryptoType cryptoType) {
this.keyStore = keyStore;
this.cryptoType = cryptoType;
}
/**
* Creates a new {@link CryptoEngine} for the given member.
*
* @param memberId member id
* @return crypto engine instance
*/
@Override
public CryptoEngine create(String memberId) {
return new TokenCryptoEngine(memberId, keyStore, cryptoType);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
cf4c20f86ae9648e01ad8c05182d637e1872a8e5 | ba79a3a346cf042fd00862f837b26cce46f02862 | /jOOQ/src/main/java/org/jooq/impl/Alias.java | d7e7341e0874b836198f6f94db26774d31565203 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | cybernetics/jOOQ | f11b6fab65bc35d9a7a5d237bdfa4f8e08606454 | ab29b4a73f5bbe027eeff352be5a75e70db9760a | refs/heads/master | 2021-01-14T10:56:49.403491 | 2014-03-12T19:21:08 | 2014-03-12T19:21:08 | 17,720,222 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,024 | java | /**
* Copyright (c) 2009-2014, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* =============================================================================
* You may choose which license applies to you:
*
* - If you're using this work with Open Source databases, you may choose
* either ASL or jOOQ License.
* - If you're using this work with at least one commercial database, you must
* choose jOOQ License
*
* For more information, please visit http://www.jooq.org/licenses
*
* Apache Software License 2.0:
* -----------------------------------------------------------------------------
* 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.
*
* jOOQ License and Maintenance Agreement:
* -----------------------------------------------------------------------------
* Data Geekery grants the Customer the non-exclusive, timely limited and
* non-transferable license to install and use the Software under the terms of
* the jOOQ License and Maintenance Agreement.
*
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
*/
package org.jooq.impl;
import static java.util.Arrays.asList;
import static org.jooq.Clause.FIELD;
import static org.jooq.Clause.FIELD_ALIAS;
import static org.jooq.Clause.FIELD_REFERENCE;
import static org.jooq.Clause.TABLE;
import static org.jooq.Clause.TABLE_ALIAS;
import static org.jooq.Clause.TABLE_REFERENCE;
// ...
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.HSQLDB;
// ...
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
import static org.jooq.impl.DSL.falseCondition;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.select;
import static org.jooq.impl.Utils.list;
import org.jooq.BindContext;
import org.jooq.Clause;
import org.jooq.Context;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.RenderContext;
import org.jooq.SQLDialect;
import org.jooq.Select;
import org.jooq.Table;
/**
* @author Lukas Eder
*/
class Alias<Q extends QueryPart> extends AbstractQueryPart {
private static final long serialVersionUID = -2456848365524191614L;
private static final Clause[] CLAUSES_TABLE_REFERENCE = { TABLE, TABLE_REFERENCE };
private static final Clause[] CLAUSES_TABLE_ALIAS = { TABLE, TABLE_ALIAS };
private static final Clause[] CLAUSES_FIELD_REFERENCE = { FIELD, FIELD_REFERENCE };
private static final Clause[] CLAUSES_FIELD_ALIAS = { FIELD, FIELD_ALIAS };
private final Q wrapped;
private final String alias;
private final String[] fieldAliases;
private final boolean wrapInParentheses;
Alias(Q wrapped, String alias) {
this(wrapped, alias, null, false);
}
Alias(Q wrapped, String alias, boolean wrapInParentheses) {
this(wrapped, alias, null, wrapInParentheses);
}
Alias(Q wrapped, String alias, String[] fieldAliases) {
this(wrapped, alias, fieldAliases, false);
}
Alias(Q wrapped, String alias, String[] fieldAliases, boolean wrapInParentheses) {
this.wrapped = wrapped;
this.alias = alias;
this.fieldAliases = fieldAliases;
this.wrapInParentheses = wrapInParentheses;
}
final Q wrapped() {
return wrapped;
}
@Override
public final void toSQL(RenderContext context) {
if (context.declareFields() || context.declareTables()) {
SQLDialect dialect = context.configuration().dialect();
boolean simulateDerivedColumnList = false;
// [#1801] Some databases don't allow "derived column names" in
// "simple class specifications". Hence, wrap the table reference in
// a subselect
if (fieldAliases != null && asList(CUBRID, FIREBIRD).contains(dialect.family()) && wrapped instanceof TableImpl) {
@SuppressWarnings("unchecked")
Select<Record> select =
select(list(field("*"))).from(((Table<?>) wrapped).as(alias));
context.sql("(").formatIndentStart().formatNewLine()
.visit(select).formatIndentEnd().formatNewLine()
.sql(")");
}
// [#1801] Some databases do not support "derived column names".
// They can be simulated by concatenating a dummy SELECT with no
// results using UNION ALL
else if (fieldAliases != null && asList(H2, MARIADB, MYSQL, SQLITE).contains(dialect.family())) {
simulateDerivedColumnList = true;
SelectFieldList fields = new SelectFieldList();
for (String fieldAlias : fieldAliases) {
switch (dialect.family()) {
/* [pro] xx
xxxx xxxxxxx x
xx xxxxxxxxxxx xx xxxxxx xxxxxxx xxxx xxxxx xxxxxxxxx xxxxx xx x xxxxxxx xxxxxxxxx
xx xx xxx xxxxx xxxxxxxxx xxxxxxx xx xxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxx
x
xx [/pro] */
default: {
fields.add(field("null").as(fieldAlias));
break;
}
}
}
Select<Record> select =
select(fields).where(falseCondition()).unionAll(
select(field("*")).from(((Table<?>) wrapped).as(alias)));
context.sql("(").formatIndentStart().formatNewLine()
.visit(select).formatIndentEnd().formatNewLine()
.sql(")");
}
// The default behaviour
else {
toSQLWrapped(context);
}
// [#291] some aliases cause trouble, if they are not explicitly marked using "as"
toSQLAs(context);
context.sql(" ");
context.literal(alias);
// [#1801] Add field aliases to the table alias, if applicable
if (fieldAliases != null && !simulateDerivedColumnList) {
toSQLDerivedColumnList(context);
}
else {
// [#756] If the aliased object is an anonymous table (usually an
// unnested array), then field names must be part of the alias
// declaration. For example:
//
// SELECT t.column_value FROM UNNEST(ARRAY[1, 2]) AS t(column_value)
// TODO: Is this still needed?
switch (dialect) {
case HSQLDB:
case POSTGRES: {
// The javac compiler doesn't like casting of generics
Object o = wrapped;
if (context.declareTables() && o instanceof ArrayTable) {
ArrayTable table = (ArrayTable) o;
context.sql("(");
Utils.fieldNames(context, table.fields());
context.sql(")");
}
break;
}
}
}
}
else {
context.literal(alias);
}
}
static void toSQLAs(RenderContext context) {
if (asList(DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES).contains(context.configuration().dialect())) {
context.sql(" ").keyword("as");
}
}
private void toSQLWrapped(RenderContext context) {
context.sql(wrapInParentheses ? "(" : "")
.visit(wrapped)
.sql(wrapInParentheses ? ")" : "");
}
private void toSQLDerivedColumnList(RenderContext context) {
String separator = "";
context.sql("(");
for (int i = 0; i < fieldAliases.length; i++) {
context.sql(separator);
context.literal(fieldAliases[i]);
separator = ", ";
}
context.sql(")");
}
@Override
public final void bind(BindContext context) {
if (context.declareFields() || context.declareTables()) {
context.visit(wrapped);
}
else {
// Don't bind any values
}
}
@Override
public final Clause[] clauses(Context<?> ctx) {
if (ctx.declareFields() || ctx.declareTables()) {
if (wrapped instanceof Table)
return CLAUSES_TABLE_ALIAS;
else
return CLAUSES_FIELD_ALIAS;
}
else {
if (wrapped instanceof Table)
return CLAUSES_TABLE_REFERENCE;
else
return CLAUSES_FIELD_REFERENCE;
}
}
@Override
public final boolean declaresFields() {
return true;
}
@Override
public final boolean declaresTables() {
return true;
}
}
| [
"lukas.eder@gmail.com"
] | lukas.eder@gmail.com |
ecb0c047447ea7d4264400a7f02bcf425f538ac4 | 8742613d9a8697581ffe8e9db9dc54ab8649d826 | /openIM/src/main/java/com/open/im/activity/RegisterActivity.java | aaf768e5e219450fa089c135c541a7a87b802f8d | [] | no_license | zhlee-cf/TestLib | 8b41fbf81f60b8e3faeb3a86dcb16b5781c3ba6e | 5dc95e5e09797f0e156c366b3b3f6b57732c3235 | refs/heads/master | 2020-02-26T15:27:37.345518 | 2016-07-12T07:18:50 | 2016-07-12T07:18:50 | 63,135,644 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,107 | java | package com.open.im.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.open.im.R;
import com.open.im.app.MyApp;
import com.open.im.utils.MyBase64Utils;
import com.open.im.utils.MyConstance;
import com.open.im.utils.MyUtils;
import com.open.im.utils.ThreadUtil;
import com.open.im.utils.XMPPConnectionUtils;
import com.open.im.view.MyDialog;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smackx.iqregister.AccountManager;
import java.io.IOException;
public class RegisterActivity extends Activity implements View.OnClickListener {
EditText etUsername;
EditText etPwd;
private RegisterActivity act;
protected MyDialog pd;
private static final int REGISTER_SUCCESS = 101;
private static final int REGISTER_FAIL = 102;
private SharedPreferences sp;
private Button btnRegister;
private Button btnCancel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_userinfo);
initView();
init();
register();
}
private void register() {
btnRegister.setOnClickListener(this);
btnCancel.setOnClickListener(this);
}
private void initView() {
etUsername = (EditText) findViewById(R.id.et_username);
etPwd = (EditText) findViewById(R.id.et_pwd);
btnRegister = (Button) findViewById(R.id.btn_register);
btnCancel = (Button) findViewById(R.id.btn_cancel);
}
/**
* 方法 注册用户
*
* @param username
* @param password
*/
private void registerUser(final String username, final String password, final String nickname) {
ThreadUtil.runOnBackThread(new Runnable() {
@Override
public void run() {
try {
XMPPConnectionUtils.initXMPPConnection(act);
XMPPTCPConnection connection = MyApp.connection;
if (!connection.isConnected()) {
connection.connect();
}
// 获得账户管理者
AccountManager accountManager = AccountManager.getInstance(connection);
if (accountManager.supportsAccountCreation()) {
accountManager.sensitiveOperationOverInsecureConnection(true);
accountManager.createAccount(username, password);
sp.edit().putString("username", username).apply();
sp.edit().putString("password", MyBase64Utils.encodeToString(password)).apply();
sp.edit().putString("nickname", nickname).apply();
handler.sendEmptyMessage(REGISTER_SUCCESS);
// 注册成功后跳转到注册成功界面
Intent intent = new Intent(act, RegisterSuccessActivity.class);
act.startActivity(intent);
finish();
}
} catch (IOException | SmackException e) {
handler.sendEmptyMessage(REGISTER_FAIL);
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
if (e.getXMPPError().toString().contains(XMPPError.Condition.conflict.toString())) {
pdDismiss();
MyUtils.showToast(act, "用户已存在");
} else {
handler.sendEmptyMessage(REGISTER_FAIL);
}
// XMPPError: conflict - cancel
// conflict
e.printStackTrace();
} catch (XMPPException e) {
handler.sendEmptyMessage(REGISTER_FAIL);
e.printStackTrace();
}
}
});
}
private void pdDismiss() {
if (pd != null && pd.isShowing() && act != null) {
pd.dismiss();
}
}
/**
* 初始化
*/
private void init() {
act = this;
sp = getSharedPreferences(MyConstance.SP_NAME, 0);
}
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
pdDismiss();
switch (msg.what) {
case REGISTER_SUCCESS:
MyUtils.showToast(act, "注册成功");
break;
case REGISTER_FAIL:
MyUtils.showToast(act, "注册失败");
break;
default:
break;
}
}
;
};
@Override
public void onClick(View view) {
int i = view.getId();
if (i == R.id.btn_register) {
final String username = etUsername.getText().toString().trim();
final String password = etPwd.getText().toString().trim();
if (TextUtils.isEmpty(username)) {
MyUtils.showToast(act, "用户名不能为空");
return;
} else if (TextUtils.isEmpty(password)) {
MyUtils.showToast(act, "密码不能为空");
return;
}
// else if (etPwd.length() < 6) {
// MyUtils.showToast(act, "密码长度不能小于6");
// return;
// }
pd = new MyDialog(act);
pd.show();
// 注册用户 默认使用用户名作为昵称
registerUser(username, password, username);
} else if (i == R.id.btn_cancel) {
finish();
}
}
}
| [
"1281861976@qq.com"
] | 1281861976@qq.com |
4ab859a497e222b0cb4cd2ea6dd106f101901b2b | f935a21f05b561db5e487e35e5c101f91595e125 | /DesignPattern/src/com/mzw/strategy/improve/ToyDuck.java | ad35d907f55b1b7c7d2df7e272bc391c6d3d5920 | [] | no_license | ma-xiao-ba/design-pattern | 3eda955895f1dea426a906c292504cdf8ddf8e71 | ca5fbbe49708dc36889df203970c795264164eb8 | refs/heads/master | 2023-05-11T06:21:33.058097 | 2019-10-07T02:55:55 | 2019-10-07T02:55:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 397 | java | package com.mzw.strategy.improve;
public class ToyDuck extends Duck{
public ToyDuck() {
flyBehavior = new NoFlyBehavior();
}
@Override
public void display() {
System.out.println("玩具鸭");
}
//需要重写父类的所有方法
public void quack() {
System.out.println("玩具鸭不能叫~~");
}
public void swim() {
System.out.println("玩具鸭不会游泳~~");
}
}
| [
"2698471726@qq.com"
] | 2698471726@qq.com |
8ad8a42364c5f107a2d5854af88d2c52acacbb41 | 1e51ab26e8fa83bd2b030f7ffea9fe3c0725d6ba | /mall-admin-service/src/main/java/com/chris/mall/admin/service/SysUserService.java | b4611b4501d1055b58150f50cfbf4e61a5d561a7 | [] | no_license | CYChuan-Chris/Mall | 1fc2709a1a7ee849b4ca2f878af180e9a4eee583 | 2711040db9608859df4f9e95d21a35d65c25041c | refs/heads/main | 2023-01-20T11:25:52.419624 | 2020-11-28T16:09:55 | 2020-11-28T16:09:55 | 312,834,198 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,564 | java | package com.chris.mall.admin.service;
import com.chris.mall.admin.entity.SysUser;
import com.chris.mall.admin.viewobj.Login;
import com.github.pagehelper.PageInfo;
/**
* 系统用户(SysUser)表服务接口
*
* @author makejava
* @since 2020-11-22 07:56:10
*/
public interface SysUserService {
/**
* 通过ID查询单条数据
*
* @param userId 主键
* @return 实例对象
*/
SysUser queryById(Long userId);
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
PageInfo<SysUser> queryAll(int offset, int limit, String username);
/**
* 新增数据
*
* @param sysUser 实例对象
* @return 实例对象
*/
SysUser insert(SysUser sysUser);
/**
* 修改数据
*
* @param sysUser 实例对象
* @return 实例对象
*/
SysUser update(SysUser sysUser);
/**
* 通过主键删除数据
*
* @param userId 主键
* @return 是否成功
*/
boolean deleteById(Long userId);
/**
* 用户登录鉴权
*
* @param login 登录信息
* @return 鉴权信息
*/
String loginVerify(Login login);
/**
* 查询登录用户信息
*
* @param token token
* @return user
*/
SysUser getUserByToken(String token);
/**
* 登出, 删除对应的 token 记录
*
* @param token 登录信息
* @return 单条数据
*/
int logout(String token);
} | [
"62143528+CYChuan-Chris@users.noreply.github.com"
] | 62143528+CYChuan-Chris@users.noreply.github.com |
af2bafce71974b327578968196fd9af556a3eb03 | 49620ea081de48720f13e56dbb997a043670b68e | /picture_library/src/main/java/com/yalantis/ucrop/util/PictureConfig.java | 39675c2c00df7e21a54a34027b2487193f5e4734 | [] | no_license | dut3062796s/PictureSelector | 0900735f902837406212067e5ede91c9d20dbcd4 | d0a7f73e35ee78c5004855203d3a48944f6afb18 | refs/heads/master | 2021-01-15T10:50:43.583150 | 2017-01-13T04:53:51 | 2017-01-13T04:53:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,622 | java | package com.yalantis.ucrop.util;
import android.graphics.Color;
import com.yalantis.ucrop.R;
/**
* author:luck
* project:PictureSelector
* package:com.luck.picture.util
* email:893855882@qq.com
* data:17/1/5
*/
public class PictureConfig {
private int type = 1; // 获取相册类型; 1 图片 2 视频
private int copyMode = PicModeConfig.COPY_MODEL_DEFAULT; // 裁剪模式; 默认、1:1、3:4、3:2、16:9
private int maxSelectNum = PicModeConfig.SELECT_MAX_NUM; // 多选最大可选数量
private int selectMode = PicModeConfig.MODE_MULTIPLE; // 单选 or 多选
private boolean isShowCamera = true; // 是否显示相机
private boolean enablePreview = true; // 是否预览图片
private boolean enableCrop; // 是否裁剪图片,只针对单选图片有效
private boolean isPreviewVideo; // 是否可预览视频(播放)
private int imageSpanCount = 4; // 列表每行显示个数
private int themeStyle = Color.parseColor("#393a3e"); // 标题栏背景色;
private int checkedBoxDrawable = R.drawable.checkbox_selector;// 图片选择默认样式
private int cropW = PicModeConfig.COPY_WIDTH; // 裁剪宽度 如果值大于图片原始宽高 将返回原图大小
private int cropH = PicModeConfig.COPY_HEIGHT;// 裁剪高度 如果值大于图片原始宽高 将返回原图大小
private int recordVideoSecond = 0;// 录视频秒数
private int recordVideoDefinition = 0;// 视频清晰度
private boolean isCompress = false;// 是否压缩图片,默认不压缩
private boolean isCheckNumMode = false;// 是否显示QQ风格选择图片
private int previewColor = Color.parseColor("#FA632D"); // 底部预览字体颜色
private int completeColor = Color.parseColor("#FA632D"); // 底部完成字体颜色
private int bottomBgColor = Color.parseColor("#fafafa"); // 底部背景色
protected int previewBottomBgColor = Color.parseColor("#dd393a3e"); // 预览底部背景色
public int getPreviewBottomBgColor() {
return previewBottomBgColor;
}
public void setPreviewBottomBgColor(int previewBottomBgColor) {
this.previewBottomBgColor = previewBottomBgColor;
}
public int getBottomBgColor() {
return bottomBgColor;
}
public void setBottomBgColor(int bottomBgColor) {
this.bottomBgColor = bottomBgColor;
}
public int getPreviewColor() {
return previewColor;
}
public void setPreviewColor(int previewColor) {
this.previewColor = previewColor;
}
public int getCompleteColor() {
return completeColor;
}
public void setCompleteColor(int completeColor) {
this.completeColor = completeColor;
}
public boolean isCheckNumMode() {
return isCheckNumMode;
}
public void setCheckNumMode(boolean checkNumMode) {
isCheckNumMode = checkNumMode;
}
public int getRecordVideoDefinition() {
return recordVideoDefinition;
}
public void setRecordVideoDefinition(int recordVideoDefinition) {
this.recordVideoDefinition = recordVideoDefinition;
}
public int getRecordVideoSecond() {
return recordVideoSecond;
}
public void setRecordVideoSecond(int recordVideoSecond) {
this.recordVideoSecond = recordVideoSecond;
}
public int getImageSpanCount() {
return imageSpanCount;
}
public void setImageSpanCount(int imageSpanCount) {
this.imageSpanCount = imageSpanCount;
}
public boolean isCompress() {
return isCompress;
}
public void setCompress(boolean compress) {
isCompress = compress;
}
public int getCropW() {
return cropW;
}
public void setCropW(int cropW) {
this.cropW = cropW;
}
public int getCropH() {
return cropH;
}
public void setCropH(int cropH) {
this.cropH = cropH;
}
public int getCheckedBoxDrawable() {
return checkedBoxDrawable;
}
public void setCheckedBoxDrawable(int checkedBoxDrawable) {
this.checkedBoxDrawable = checkedBoxDrawable;
}
public int getThemeStyle() {
return themeStyle;
}
public void setThemeStyle(int themeStyle) {
this.themeStyle = themeStyle;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getCopyMode() {
return copyMode;
}
public void setCopyMode(int copyMode) {
this.copyMode = copyMode;
}
public int getMaxSelectNum() {
return maxSelectNum;
}
public void setMaxSelectNum(int maxSelectNum) {
this.maxSelectNum = maxSelectNum;
}
public int getSelectMode() {
return selectMode;
}
public void setSelectMode(int selectMode) {
this.selectMode = selectMode;
}
public boolean isShowCamera() {
return isShowCamera;
}
public void setShowCamera(boolean showCamera) {
isShowCamera = showCamera;
}
public boolean isEnablePreview() {
return enablePreview;
}
public void setEnablePreview(boolean enablePreview) {
this.enablePreview = enablePreview;
}
public boolean isEnableCrop() {
return enableCrop;
}
public void setEnableCrop(boolean enableCrop) {
this.enableCrop = enableCrop;
}
public boolean isPreviewVideo() {
return isPreviewVideo;
}
public void setPreviewVideo(boolean previewVideo) {
isPreviewVideo = previewVideo;
}
}
| [
"893855882@qq.com"
] | 893855882@qq.com |
58ce5f2811bb56bd4872ca1bf1827b854196133f | 90772689067edfe4ae027aab914994381d1034a6 | /hrmsSpring/src/main/java/com/seyitucar/hrmsSpring/api/controllers/EmployeesController.java | 08f4194c7fe96d2c24bb5d93909246b5d88b404d | [] | no_license | seyitucar/hrms-backend | 93b48b1d29a0e8126cc691a50788b7ca0619d7ba | 3f3e677fa04582b7e9db138bc45a0d3b0bd15c52 | refs/heads/master | 2023-08-22T21:24:47.745714 | 2021-09-28T22:49:08 | 2021-09-28T22:49:08 | 399,203,460 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,866 | java | package com.seyitucar.hrmsSpring.api.controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.seyitucar.hrmsSpring.business.abstracts.EmployeeService;
import com.seyitucar.hrmsSpring.core.utilities.results.DataResult;
import com.seyitucar.hrmsSpring.core.utilities.results.Result;
import com.seyitucar.hrmsSpring.entities.concretes.Employee;
@CrossOrigin
@RestController
@RequestMapping("/api/employees")
public class EmployeesController {
private EmployeeService employeeService;
@Autowired
public EmployeesController(EmployeeService employeeService) {
super();
this.employeeService = employeeService;
}
@PostMapping("/add")
public Result register(@RequestBody Employee employee){
return this.employeeService.register(employee);
}
@PostMapping("/login")
public Result login(@RequestBody String email){
return this.employeeService.logIn(email);
}
@PostMapping("/update")
public Result update(@RequestBody Employee employee ) {
return this.employeeService.update(employee);
}
@PostMapping("/delete")
public Result delete(@RequestParam int id) {
return this.employeeService.delete(id);
}
@GetMapping("/getall")
public DataResult<List<Employee>> getAll(){
return this.employeeService.getAll();
}
@GetMapping("/getById")
public DataResult<Employee> getById(@RequestParam int id){
return this.employeeService.findById(id);
}
}
| [
"sytucar@hotmail.com"
] | sytucar@hotmail.com |
37b08d51cd4738d710e2b5bc108dc0bed3dbbf7d | 89d0ba81bb48b6d9bc868decd902965345435348 | /src/main/java/jp/co/tis/s2n/javaConverter/convert/logic/ConvertAction.java | 3ca83a616565eeb4a524b4ff52ed1eec370a5813 | [
"Apache-2.0"
] | permissive | oscana/oscana-s2n-javaconverter | 75cd6ad8c4e2eec9c9bd59259789dcf357a7df64 | 7aa672cbfb4fefa973632dabca1d43d011bc60ab | refs/heads/master | 2023-03-31T15:37:00.802181 | 2021-03-30T10:32:25 | 2021-03-30T10:32:25 | 291,641,914 | 0 | 0 | Apache-2.0 | 2021-03-30T10:32:25 | 2020-08-31T07:10:12 | Java | UTF-8 | Java | false | false | 19,032 | java | package jp.co.tis.s2n.javaConverter.convert.logic;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import jp.co.tis.s2n.converterCommon.struts.analyzer.ClassPathConvertUtil;
import jp.co.tis.s2n.converterCommon.struts.analyzer.StrutsAnalyzeResult;
import jp.co.tis.s2n.converterCommon.struts.analyzer.StrutsAnalyzer;
import jp.co.tis.s2n.converterCommon.struts.analyzer.output.Route;
import jp.co.tis.s2n.converterCommon.struts.analyzer.output.StrutsAction;
import jp.co.tis.s2n.converterCommon.util.StringUtils;
import jp.co.tis.s2n.javaConverter.convert.profile.S2nProfile;
import jp.co.tis.s2n.javaConverter.convert.program.ReturnStatementHandler;
import jp.co.tis.s2n.javaConverter.convert.statistics.ActionStatistics;
import jp.co.tis.s2n.javaConverter.node.AnnotationNodeUtil;
import jp.co.tis.s2n.javaConverter.node.FieldNodeUtil;
import jp.co.tis.s2n.javaConverter.node.Node;
import jp.co.tis.s2n.javaConverter.node.NodeUtil;
import jp.co.tis.s2n.javaConverter.token.Token;
/**
* Actionクラスの変換処理。
*
* @author Fumihiko Yamamoto
*
*/
public class ConvertAction extends ConvertBase {
/** * メソッド前挿入用アダプタ パーツ*/
private static final String XENLON_S2N_CONVERT_XENLON_STRUTS_ACTION_INJECT_PARTS_VM = "templete/StrutsActionInjectParts.vm";
/** * メソッド前挿入用アダプタ パーツ*/
private static final String XENLON_S2N_CONVERT_XENLON_SASTRUTS_ACTION_INJECT_PARTS_VM = "templete/SAStrutsActionInjectParts.vm";
/**
* Actionクラス変換の主処理。
* @param fileName 変換ファイル名
* @param topNode トップノード
* @throws Exception 例外
*/
public void convertProc(String fileName, Node topNode) throws Exception {
super.convertProc(fileName, topNode);
List<Node> classNodeList = NodeUtil.findAllNode(topNode, Node.T_CLASS);
Node classNode = classNodeList.get(0);
//完全修飾クラス名特定
String packageName = NodeUtil.getPackageName(topNode);
//編集前の状態でクラスネームリゾルバを作成
makeClassNameResolver(topNode, packageName);
String className = NodeUtil.getClassName(topNode);
String fullClassName = StringUtils.addClassPackage(packageName, className);
String actionName = getActionName(className);
//@ActioFormがついているフォームを見つける
FieldNodeUtil saForm = convertAndFindForm(fileName, topNode);
if(activeProfile.getConvertMode() == S2nProfile.CONVERT_MODE_XENLON) {
convertTokenSkipMethod(topNode);
}
//アクションメソッドの変換処理
//Struts.xmlに基づく変換
if (this.strutsAnalyzeResult != null) {
//Struts.xmlに基づく変換
convertStrutsAction(fileName, classNode, fullClassName);
}
//@Executeがついてるメソッドを変換する
convertExecuteMethod(topNode, classNode, saForm, actionName);
//ファイルの種類によらない変換を実施
convertCommon(topNode, fileName, classNode);
//追加import挿入
insertStrutsImportInjectParts(topNode, "Action");
}
/**
* Struts.xmlに基づく変換を実施する。
* @param fileName ファイル名
* @param classNode クラスノード
* @param fullClassName 完全修飾クラス名
*/
private void convertStrutsAction(String fileName, Node classNode, String fullClassName) {
List<StrutsAction> actionList = new ArrayList<StrutsAction>();
for (StrutsAnalyzeResult analyzeResult : this.strutsAnalyzeResult) {
List<StrutsAction> cActionList = analyzeResult.getActionList().stream()
.filter((action) -> fullClassName.equals(action.getType())).collect(Collectors.toList());
if (cActionList.size() > 0) {
actionList.addAll(cActionList);
}
}
StrutsAction curAction = null;
if (actionList.size() > 1) {
curAction = actionList.get(0);
} else if (actionList.size() == 1) {
curAction = actionList.get(0);
}
println("StrutsAction置換:" + fullClassName);
if (curAction != null) {
//Action変換メソッド挿入
insertStrutsActionInjectParts(classNode, curAction);
//クラスにアノテーションを付与
addScopeAnotationToClass(classNode, "@RequestScoped");
}
}
/**
* @ActionFormアノテーションが付与されているメンバを見つけ、メンバ名を返す。
* @param fileName ファイル名
* @param topNode トップノード
* @return フィールドノードユーティリティ
*/
private FieldNodeUtil convertAndFindForm(String fileName, Node topNode) {
// アノテーション・ノードの取得
FieldNodeUtil retObj = null;
List<Node> annotations = NodeUtil.findAllNode(topNode, "@ActionForm");
boolean findForm = false;
for (Node annotation : annotations) {
// アノテーションが付与されているメンバ・ノードを取得する。
Node fieldNode = NodeUtil.searchNodeForAnnotation(annotation);
if (findForm == false) {
//メンバ名を見つける
retObj = new FieldNodeUtil(fieldNode);
findForm = true;
// @ActionFormを@OscanaActionFormに変換
annotation.setName("@OscanaActionForm");
}
}
return retObj;
}
/**
* Executeアノテーションがついているメソッドはアクションとして変換を実施する。<br>
* Executeアノテーションノードが見つからなければこのクラスはアクションではないので何もしない。
* @param topNode トップノード
* @param classNode クラスノード
* @param saForm フィールドノードのオブジェクト
* @param actionName アクション名
*/
private void convertExecuteMethod(Node topNode, Node classNode, FieldNodeUtil saForm, String actionName) {
boolean isAction = false;
// アノテーション・ノードの取得
List<Node> annotations = NodeUtil.findAllNode(topNode, "@Execute");
String packageName = NodeUtil.getPackageName(topNode);
for (Node annotation : annotations) {
AnnotationNodeUtil executeAnnotation = new AnnotationNodeUtil(annotation);
// アノテーションが付与されているメソッド・ノードを取得する。
Node methodNode = NodeUtil.searchNodeForAnnotation(annotation);
if (methodNode != null) {
// メソッド名を取得
String methodName = methodNode.getParams().get(methodNode.getPosOfParams("(") - 1).getText();
isAction = true;
String beforeChange = methodNode.getString();//ログ用変更前文字列
// 返り値の変更
methodNode.replaceParams("String", "HttpResponse");
// 引数の追加位置の取得
int pos = methodNode.getPosOfParams(")");
if (pos != -1) {
// 引数の追加
methodNode.addParamPos(pos,
new Token(Token.NAME, "HttpRequest nabRequest, ExecutionContext nabContext"));
// メソッドを使ってるところ
List<Node> callerList = NodeUtil.findAllNode(topNode, methodName);
for (Node caller : callerList) {
// メソッド自身を除外
if (methodNode.getLineNo() == caller.getLineNo()) {
continue;
}
int callerPos = -1;
int posIns = -1;
List<Token> tokens = caller.getParams();
for (int i = 0; i < tokens.size(); i++) {
if (tokens.get(i).getText().equals(methodName)) {
callerPos = i;
}
if (tokens.get(i).getText().equals(")")) {
posIns = i;
}
if (callerPos > 0 && posIns > callerPos) {
break;
}
}
// シグネチャに合わせる、パラメータを追加 ※括弧ネストの場合未対応
if (posIns != -1) {
caller.addParamPos(posIns, new Token(Token.NAME, "nabRequest, nabContext"));
}
}
}
//Route.xmlに出力用データを作成
insertRouteXml(executeAnnotation, topNode, actionName, methodName);
//メソッド前の処理挿入
insertSAStrutsActionInjectParts(methodNode, actionName, saForm, executeAnnotation, topNode);
//Returnの変更
List<Node> returnList = NodeUtil.findAllNode(methodNode, "return");
for (Node retrunNode : returnList) {
new ReturnStatementHandler(actionName, cnr).convert(retrunNode, null, null);
}
ActionStatistics.getInstance().convertedAction(packageName, actionName, beforeChange,
methodNode.getString());
}
//Executeアノテーションは消去
NodeUtil.removeChildNode(annotation);
}
if (isAction) {
//Actionむけ追加処理
//クラスにアノテーションを付与
addScopeAnotationToClass(classNode, "@RequestScoped");
}
}
/**
*
* アクションクラスに対して、publicメソッドに「@OnDoubleSubmission」を追加する。<br>
* ただ、TokenSkipアノテーションがついているメソッドでは、追加不要。<br>
*
* OnDoubleSubmissionのパスは、設定ファイルに指定する。
*
* @param topNode トップノード
*/
private void convertTokenSkipMethod(Node topNode) {
// メソッド一覧を取得する
List<Node> nodeList = NodeUtil.findAllNode(topNode, Node.T_BLOCK);
List<Node> findList = new ArrayList<>();
for (Node node : nodeList) {
if (node.getName().equals("public")) {
// 対象メソッドに付与されたアノテーションのリストを返す
findList = NodeUtil.getAnnotationList(node);
boolean isSkip = true;
for (Node methodNode : findList) {
if (methodNode.getName().equals("@TokenSkip")) {
// TokenSkipアノテーションを削除
NodeUtil.removeChildNode(methodNode);
isSkip = true;
break;
} else if(methodNode.getName().equals("@Execute")) {
isSkip = false;
}
}
if (!isSkip) {
int index = node.getParent().getChildren().indexOf(node);
String onDoubleSubmissionAnnotation = "@OnDoubleSubmission" + "(path=\""
+ this.activeProfile.getOnDoubleSubmissionPath() + "\")";
//publicメソッドに「@OnDoubleSubmission」を追加する
NodeUtil.addChildNode(node.getParent(), index,
Node.create(Node.T_ANNOTATION, onDoubleSubmissionAnnotation));
}
}
}
}
/**
* StrutsActionに固定のアダプタパーツを挿入する。
* @param classNode クラスノード
* @param curAction アクションクラス
*/
private void insertStrutsActionInjectParts(Node classNode, StrutsAction curAction) {
String module = curAction.getStrutsAnalyzeResult().getModule();
VelocityContext context = new VelocityContext();
context.put("errorjsp", StrutsAnalyzer.resolveForward(curAction.getInputAndResolveForward(),
curAction.getStrutsAnalyzeResult()));
context.put("module", module);
context.put("action", curAction);
context.put("forwardList", curAction.getForwardList());
if (curAction.getForm() != null) {
context.put("form", StringUtils.getClassShortName(curAction.getForm().getType()));
}
if(curAction.getValidate() == null) {
context.put("isValidate", true);
} else {
context.put("isValidate", curAction.getValidate());
}
context.put("strutsConfig", curAction.getActionConfig());
context.put("StringUtils", new StringUtils());
if (curAction.getForm() != null) {
ClassPathConvertUtil.getInstance().addImprt(curAction.getForm().getType());
}
StringWriter sw = new StringWriter();
//テンプレートの作成
Template template = this.velocityEngine.getTemplate(XENLON_S2N_CONVERT_XENLON_STRUTS_ACTION_INJECT_PARTS_VM,
"UTF-8");
//テンプレートとマージ
template.merge(context, sw);
//マージしたデータはWriterオブジェクトであるswが持っているのでそれを文字列として出力
sw.flush();
classNode.getChildren().add(0, Node.create(Node.T_BLOCK, sw.toString()));
}
/**
* Route.xmlに出力用データを作成する。
* @param executeAnnotation アノテーションノード
* @param topNode トップノード
* @param actionName アクション名
* @param methodName メソッド名
*/
private void insertRouteXml(AnnotationNodeUtil executeAnnotation, Node topNode, String actionName, String methodName) {
String basePackage = this.activeProfile.getBasePackage();
String packageName = NodeUtil.getPackageName(topNode);
if(!packageName.contains(basePackage.trim()+".action")) {
return;
}
//controllerを生成
String controller = null;
String path = "";
if("".equals(packageName.substring((basePackage.trim()+".action").length()))){
controller = actionName;
//pathの先頭の文字を小文字にする
path = Character.toLowerCase(actionName.charAt(0)) + actionName.substring(1);
}else {
controller = packageName.substring((basePackage.trim()+".action.").length()) + "." + actionName;
//pathの先頭の文字を小文字にする
path = packageName.substring((basePackage.trim()+".action.").length()) + "." + Character.toLowerCase(actionName.charAt(0)) + actionName.substring(1);
}
//actionを生成
String action = methodName;
//pathを生成
String urlPtn = executeAnnotation.getStringValueWithoutQuote("urlPattern");
if(!StringUtils.isEmpty(urlPtn)) {
path = "/" + path.replaceAll("\\.", "\\/") + "/"
+ urlPtn.replaceAll("\"", "").replaceAll("\\+", "").replaceAll("\\{", ":").replaceAll("\\}", "");
}else {
path = "/" + path.replaceAll("\\.", "\\/") + "/" + methodName;
}
Route route = new Route(path, "", controller, action, null);
this.allRoutes.put(route.getPath(), route);
}
/**
* SAStrutsActionに固定のアダプタパーツを挿入する。
* @param methodNode メソッドノード
* @param actionName アクション名
* @param saForm フィールドノード
* @param executeAnnotation アノテーションノード
* @param topNode トップノード
*/
private void insertSAStrutsActionInjectParts(Node methodNode, String actionName, FieldNodeUtil saForm,
AnnotationNodeUtil executeAnnotation, Node topNode) {
VelocityContext context = new VelocityContext();
String validator = executeAnnotation.getStringValueWithoutQuote("validator");
boolean isValidate = true;
if (!StringUtils.isEmpty(validator)) {
isValidate = Boolean.valueOf(validator);
}
context.put("input", executeAnnotation.getStringValueWithoutQuote("input"));
String basePackage = this.activeProfile.getBasePackage();
String packageName = NodeUtil.getPackageName(topNode);
String errorPath = "";
if(packageName.contains(basePackage.trim()+".action.")) {
errorPath = packageName.substring((basePackage.trim()+".action.").length()) + "/" + Character.toLowerCase(actionName.charAt(0)) + actionName.substring(1);
} else {
errorPath = Character.toLowerCase(actionName.charAt(0)) + actionName.substring(1);
}
context.put("action", errorPath);
if (saForm != null) {
context.put("formClass", saForm.getClassName());
}
context.put("isValidate", isValidate);
context.put("validate", executeAnnotation.getStringValueWithoutQuote("validate"));
context.put("reset", executeAnnotation.getStringValueWithoutQuote("reset"));
context.put("removeActionForm", executeAnnotation.getStringValueWithoutQuote("removeActionForm"));
context.put("stopOnValidationError", executeAnnotation.getStringValueWithoutQuote("stopOnValidationError"));
StringWriter sw = new StringWriter();
//テンプレートの作成
Template template = this.velocityEngine.getTemplate(XENLON_S2N_CONVERT_XENLON_SASTRUTS_ACTION_INJECT_PARTS_VM,
"UTF-8");
//テンプレートとマージ
template.merge(context, sw);
//マージしたデータはWriterオブジェクトであるswが持っているのでそれを文字列として出力
sw.flush();
int pos = methodNode.getParent().getChildren().indexOf(methodNode);
NodeUtil.addChildNode(methodNode.getParent(), pos, Node.create(Node.T_BLOCK, sw.toString()));
}
/**
* クラス名に対するアクション名を取得する。
* @param className クラス名
* @return Actionを除いたクラス名
*/
private String getActionName(String className) {
String subPath;
if (className.endsWith("Action")) {
subPath = className.substring(0, className.length() - "Action".length());
} else {
subPath = className;
}
return subPath;
}
}
| [
"ko.i@tis.co.jp"
] | ko.i@tis.co.jp |
b5790c16035d888992813917fde404df518f7cf9 | cd1c15574bf78df62b7dc6e8461d9b728b121436 | /src/cz/zcu/kiv/os/core/device/AbstractDevice.java | efccb8ec14ebc0850ee3bf04589eff75b58bf15d | [] | no_license | bydga/kiv.os | cece797d067d2211b88764993f6b2033aa2e7e62 | 76bf77a393043bb997e61a0102dc94a41cea6d85 | refs/heads/master | 2021-01-01T18:34:02.953356 | 2012-11-29T22:20:37 | 2012-11-29T22:20:37 | 6,140,716 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,092 | java | package cz.zcu.kiv.os.core.device;
import java.io.IOException;
/**
* Basic implementation of IDevice interface. Provides basic means for determining
* whether the device is open or not.
*
* @author Jakub Danek
*/
public abstract class AbstractDevice implements IDevice {
private boolean open;
private boolean stdStream;
protected AbstractDevice(boolean stdStream) {
open = true;
this.stdStream = stdStream;
}
@Override
public boolean isOpen() {
return open;
}
@Override
public synchronized void detach() throws IOException {
if(open) {
open = false;
this.detachAction();
}
}
@Override
public boolean isStdStream() {
return stdStream;
}
/**
* Override this action to provide any actions that need to be done upon
* device close.
*
* If explicitly called by child class or another package class, must be synchronized
* via the owning instance monitor!!!
*/
protected abstract void detachAction() throws IOException;
}
| [
"jakub.danek@yoso.fi"
] | jakub.danek@yoso.fi |
b084215d854b02ccdb51a53e6aed32ad18d5c065 | f86187d88375939cc299b361af3dc84cd9f705c4 | /EclipseDevelop_JavaEE2/baiHoo.invoice-master/src/main/java/com/baiHoo/web/buss/controller/TBBranchController.java | 47133fda6c335a155f02e19d090d4a639e42dc94 | [] | no_license | ChenBaiHong/baihoo.EclipseDataBank | 83c7b5ceccf80eea5e8b606893463d2d98a53d67 | e4698c40f2a1d3ffc0be07115838234aebb8ba95 | refs/heads/master | 2020-03-26T11:45:49.204873 | 2018-08-15T14:37:38 | 2018-08-15T14:37:38 | 144,859,060 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,678 | java | package com.baiHoo.web.buss.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.baiHoo.core.common.controller.BaseController;
import com.baiHoo.core.common.exception.BusinessException;
import com.baiHoo.core.common.hibernate.qbc.CriteriaQuery;
import com.baiHoo.core.common.model.json.AjaxJson;
import com.baiHoo.core.common.model.json.DataGrid;
import com.baiHoo.core.constant.Globals;
import com.baiHoo.core.util.MyBeanUtils;
import com.baiHoo.core.util.StringUtil;
import com.baiHoo.tag.core.easyui.TagUtil;
import com.baiHoo.web.buss.entity.base.TBBranchEntity;
import com.baiHoo.web.buss.service.TBBranchServiceI;
import com.baiHoo.web.system.service.SystemService;
/**
*
*<p>Title: TBBranchController</p>
*<p>Description:
*
* 分公司表
*
*</p>
*<p>Company: www.baiHoo.com</p>
* @author baiHoo.chen
* @date May 8, 2017
*/
@SuppressWarnings("all")
@Controller
@RequestMapping("/tBBranchController")
public class TBBranchController extends BaseController {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(TBBranchController.class);
@Autowired
private TBBranchServiceI tBBranchService;
@Autowired
private SystemService systemService;
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
/**
* 分公司表列表 页面跳转
*
* @return
*/
@RequestMapping(params = "tBBranch")
public ModelAndView tBBranch(HttpServletRequest request) {
return new ModelAndView("buss/branch/tBBranchList");
}
/**
* 选择分部
*
* @return
*/
@RequestMapping(params = "tBBranchSelect")
public String branch() {
return "buss/branch/tBBranchSelect";
}
/**
* 分部显示列表
*
* @param request
* @param response
* @param dataGrid
*/
@RequestMapping(params = "datagridBranch")
public void datagridBranch(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(TBBranchEntity.class, dataGrid);
this.systemService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
* easyui AJAX请求数据
*
* @param request
* @param response
* @param dataGrid
* @param user
*/
@RequestMapping(params = "datagrid")
public void datagrid(TBBranchEntity tBBranch,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(TBBranchEntity.class, dataGrid);
//查询条件组装器
com.baiHoo.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tBBranch, request.getParameterMap());
try{
//自定义追加查询条件
}catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
this.tBBranchService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
/**
* 删除分公司表
*
* @return
*/
@RequestMapping(params = "doDel")
@ResponseBody
public AjaxJson doDel(TBBranchEntity tBBranch, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
tBBranch = systemService.getEntity(TBBranchEntity.class, tBBranch.getId());
message = "分公司表删除成功";
try{
tBBranchService.delete(tBBranch);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "分公司表删除失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 批量删除分公司表
*
* @return
*/
@RequestMapping(params = "doBatchDel")
@ResponseBody
public AjaxJson doBatchDel(String ids,HttpServletRequest request){
AjaxJson j = new AjaxJson();
message = "分公司表删除成功";
try{
for(String id:ids.split(",")){
TBBranchEntity tBBranch = systemService.getEntity(TBBranchEntity.class,
id
);
tBBranchService.delete(tBBranch);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}
}catch(Exception e){
e.printStackTrace();
message = "分公司表删除失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 添加分公司表
*
* @param ids
* @return
*/
@RequestMapping(params = "doAdd")
@ResponseBody
public AjaxJson doAdd(TBBranchEntity tBBranch, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
message = "分公司表添加成功";
try{
tBBranchService.save(tBBranch);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){
e.printStackTrace();
message = "分公司表添加失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 更新分公司表
*
* @param ids
* @return
*/
@RequestMapping(params = "doUpdate")
@ResponseBody
public AjaxJson doUpdate(TBBranchEntity tBBranch, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
message = "分公司表更新成功";
TBBranchEntity t = tBBranchService.get(TBBranchEntity.class, tBBranch.getId());
try {
MyBeanUtils.copyBeanNotNull2Bean(tBBranch, t);
tBBranchService.saveOrUpdate(t);
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) {
e.printStackTrace();
message = "分公司表更新失败";
throw new BusinessException(e.getMessage());
}
j.setMsg(message);
return j;
}
/**
* 分公司表新增页面跳转
*
* @return
*/
@RequestMapping(params = "goAdd")
public ModelAndView goAdd(TBBranchEntity tBBranch, HttpServletRequest req) {
if (StringUtil.isNotEmpty(tBBranch.getId())) {
tBBranch = tBBranchService.getEntity(TBBranchEntity.class, tBBranch.getId());
req.setAttribute("tBBranchPage", tBBranch);
}
return new ModelAndView("buss/branch/tBBranch-add");
}
/**
* 分公司表编辑页面跳转
*
* @return
*/
@RequestMapping(params = "goUpdate")
public ModelAndView goUpdate(TBBranchEntity tBBranch, HttpServletRequest req) {
if (StringUtil.isNotEmpty(tBBranch.getId())) {
tBBranch = tBBranchService.getEntity(TBBranchEntity.class, tBBranch.getId());
req.setAttribute("tBBranchPage", tBBranch);
}
return new ModelAndView("buss/branch/tBBranch-update");
}
}
| [
"cbh12345661@hotmail.com.cn"
] | cbh12345661@hotmail.com.cn |
1ed19da230437a8db1d0c14df697d8cc7c564536 | b4be2ce4c339137b45b7d7b1c567ebb28970a926 | /src/me/hii488/volcanoRush/containers/generationAlgs/GenerationAlg.java | 147d0a682029a9c1dde98e0ff8506dfe4972bd79 | [
"MIT"
] | permissive | Elendrial/VolcanoRush | d1d22c298af8fbd40c92f8acc0ec4e84808644da | c98d1b237bded2baabf9d486615b68e77f27c24f | refs/heads/master | 2021-09-06T21:35:04.511502 | 2018-02-11T21:06:27 | 2018-02-11T21:06:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 433 | java | package me.hii488.volcanoRush.containers.generationAlgs;
import me.hii488.misc.Grid;
import me.hii488.misc.Vector;
import me.hii488.volcanoRush.dataTypes.OreType;
public abstract class GenerationAlg {
public abstract void populate(Grid g);
public abstract void populate(Grid g, long seed);
public abstract OreType getOreType(int x, int y);
public OreType getOreType(Vector v){
return getOreType(v.getX(), v.getY());
}
}
| [
"hii488@btinternet.com"
] | hii488@btinternet.com |
188e3df0032cd652159bc8af4cfd46e73644e57b | 0177aec85b5e7f394957679e9849394366586872 | /src/test/java/jpabook/jpashop/repository/MemberServiceTest.java | 9eb5d51e4b12f03aa1b3b662f9718a800b7ee72f | [] | no_license | jihoho/jpashop | fee15f4860aa418950d829ca127f55b9e4ff8a52 | 712923a68f8c7cdd864684138e7a1529b60a54d9 | refs/heads/master | 2023-05-03T08:53:21.929156 | 2021-05-24T07:19:28 | 2021-05-24T07:19:28 | 353,290,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,561 | java | package jpabook.jpashop.repository;
import static org.junit.Assert.*;
import jpabook.jpashop.Service.MemberService;
import jpabook.jpashop.domain.Member;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by IntelliJ IDEA
* User: hojun
* Date: 2021-04-09 Time: 오전 7:10
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class MemberServiceTest {
@Autowired
MemberService memberService;
@Autowired
MemberRepository memberRepository;
@Test
@Rollback(false)
public void 회원가입() throws Exception {
// given
Member member = new Member();
member.setName("kim");
// when
Long savedId = memberService.join(member);
// then
assertEquals(member, memberRepository.findOne(savedId));
}
@Test(expected = IllegalStateException.class)
public void 중복_회원_예외() throws Exception {
// given
Member member1 = new Member();
member1.setName("kim");
Member member2 = new Member();
member2.setName("kim");
// when
memberService.join(member1);
memberService.join(member2);
// then
fail("예외가 발생해야 한다.");
}
} | [
"xkftn94@naver.com"
] | xkftn94@naver.com |
c9c0908f5531c71191549626fb32aed29c9717bd | 55ed2c6df4ac38f5bc42f9b66b95c46659ba55e3 | /browser-test/src/main/java/org/apx/testing/elements/primefaces/PFRadio.java | a5aa8ff4cb9bf193cb13dd3d257fa4e6ae7a02c3 | [] | no_license | Apxdono/testing-frameworks | 6a35232e8d1da077e9acbf00ccc79d82436a8e7c | f51d9f2648fac1a0c5fa768271f03f9fb235d1c6 | refs/heads/master | 2021-01-19T13:26:48.141618 | 2014-09-23T15:11:33 | 2014-09-23T15:11:33 | 21,430,466 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 773 | java | package org.apx.testing.elements.primefaces;
import org.apx.testing.elements.BaseEvent;
import org.apx.testing.elements.Element;
import org.apx.testing.elements.interfaces.Selectable;
/**
* Created by oleg on 10.07.2014.
*/
public class PFRadio extends Element<PFRadio,BaseEvent<PFRadio>> implements Selectable<PFRadio> {
@Override
public PFRadio check() {
return !hasClass("ui-state-active") ? event().click() : this;
}
@Override
public PFRadio uncheck() {
throw new UnsupportedOperationException("Radio button can't be unchecked by itself");
}
@Override
public PFRadio toggle() {
return event().click();
}
@Override
protected void initEvents() {
events = new BaseEvent<>(this);
}
}
| [
"oleg.yakovenko@km-ware.com"
] | oleg.yakovenko@km-ware.com |
d991306d1e49febb35d64994e0cc8751a4f65b90 | 4cef2578a80d0ea2fdb022e1cfb49ecbd9e62ec6 | /account-login-ms/src/main/java/com/example/demo/filter/JwtFilter.java | 1a8fd9067d016ec82e89cc671a5ca051b6e1eca9 | [] | no_license | puspakpradhan/Microservice | 22bb4995655bceb0a84e05c5c7c8d27de29644d0 | 8bc768cec614d753da2bbdb83bf767c6cce6b09f | refs/heads/main | 2023-02-13T01:17:34.106380 | 2021-01-15T17:59:18 | 2021-01-15T17:59:18 | 320,640,261 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,349 | java | package com.example.demo.filter;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import com.example.demo.service.CustomUserDetailsService;
import com.example.demo.util.JwtUtil;
@Component
public class JwtFilter extends OncePerRequestFilter {
@Autowired
private JwtUtil jwtUtil;
@Autowired
private CustomUserDetailsService service;
@Override
protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
String authorizationHeader = httpServletRequest.getHeader("Authorization");
String token = null;
String userName = null;
if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
token = authorizationHeader.substring(7);
userName = jwtUtil.extractUsername(token);
}
if (userName != null && SecurityContextHolder.getContext().getAuthentication() == null) {
UserDetails userDetails = service.loadUserByUsername(userName);
if (jwtUtil.validateToken(token, userDetails)) {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
usernamePasswordAuthenticationToken
.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
}
}
filterChain.doFilter(httpServletRequest, httpServletResponse);
}
}
| [
"pukpradh@in.ibm.com"
] | pukpradh@in.ibm.com |
d737a106d879840ebfc83247a2a3cc5b97994d2f | cabeb1eebc113ff6827cba860c9ca9207ab8fecb | /src/com/nerdSpace/GUI/LoadScreen.java | ba39ab56d8a3730ee80e346cef6752b769269dcc | [] | no_license | JibbySnip/Divergence | 9c4b030f64f1022ec135509dbf4a3e03af0ef061 | 4e2029afd49dbde4dce862c51d5c4ff517d59019 | refs/heads/master | 2022-04-08T19:24:28.047987 | 2020-03-23T02:43:21 | 2020-03-23T02:43:21 | 248,281,446 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,609 | java | package com.nerdSpace.GUI;
import javax.swing.*;
import java.util.Timer;
import java.util.TimerTask;
public class LoadScreen {
private JProgressBar progressBar;
private JLabel titleLabel;
private JPanel rootPanel;
private JLabel subtitleLabel;
private java.util.Timer loadTimer = new Timer();
int loadTime = 2;
int currTime = 0;
GuiDelegator callback;
LoadScreen(GuiDelegator callback) {
this.callback = callback;
}
public void init() {
startPBar();
titleLabel.setFont(GuiDelegator.dungeonFontLarge);
subtitleLabel.setFont(GuiDelegator.dungeonFontMedium);
rootPanel.setVisible(true);
rootPanel.validate();
}
public void update() {
runningPBar();
}
private void runningPBar() {
currTime++;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
progressBar.setValue(currTime * (100 / loadTime));//Setting value of Progress Bar
progressBar.setString((currTime * (100 / loadTime))+"%");
}
});
}
public void startPBar() {
loadTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
update();
}
}, 0, 1000);
loadTimer.schedule(new TimerTask() {
public void run() {
callback.passSplash();
loadTimer.cancel();
}
}, 1000 * (loadTime-1));
}
public JPanel getRootPanel() {
return rootPanel;
}
}
| [
"endershadowz122@gmail.com"
] | endershadowz122@gmail.com |
750c4be2c5d67963ceb7707ccbe2f088e531a5dd | 106cce45fa593bc6ef7ea105f5055b5d13d251d0 | /Examples/Github/src/generated/java/api/github/com/definitions/Branches.java | 74f06b6eafd5e9cdd7253745fb444b18c3a7117e | [] | no_license | glelouet/JSwaggerMaker | f7faf2267e900d78019db42979922d2f2c2fcb33 | 1bf9572d313406d1d9e596094714daec6f50e068 | refs/heads/master | 2022-12-08T04:28:53.468581 | 2022-12-04T14:37:47 | 2022-12-04T14:37:47 | 177,210,549 | 0 | 0 | null | 2022-12-04T14:37:48 | 2019-03-22T21:19:28 | Java | UTF-8 | Java | false | false | 853 | java | package api.github.com.definitions;
import api.github.com.definitions.branches.Commit;
public class Branches {
public Commit commit;
public String name;
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if ((other == null)||(other.getClass()!= getClass())) {
return false;
}
Branches othersame = ((Branches) other);
if ((commit!= othersame.commit)&&((commit == null)||(!commit.equals(othersame.commit)))) {
return false;
}
if ((name!= othersame.name)&&((name == null)||(!name.equals(othersame.name)))) {
return false;
}
return true;
}
public int hashCode() {
return (((commit == null)? 0 :commit.hashCode())+((name == null)? 0 :name.hashCode()));
}
}
| [
"guillaume.lelouet@gmail.com"
] | guillaume.lelouet@gmail.com |
6e10b95e9158b542a653f2dff4e42bf0a7c05347 | 3843b09d7c81a6367abb2546211fb6c05f420ae4 | /Java OOP Basics/Exams & Exam Preparations/JavaOOPBasicsExams/src/exam_08_03_2017/Center.java | 28303f5eab05e380860507cefdd832538bdb99b8 | [] | no_license | Deyan-Stoyanov/SoftUni_Java_Fundamentals | 11021a94ee3ff8908f38b038d626e1e85a57a6c3 | 987c7565d4587530d4f590d1322a8c13ad2beed6 | refs/heads/master | 2020-03-17T10:17:37.224710 | 2018-08-19T16:58:40 | 2018-08-19T16:58:40 | 133,507,185 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 891 | java | package exam_08_03_2017;
import java.util.ArrayList;
import java.util.List;
public abstract class Center {
private String name;
private List<Animal> storedAnimals;
protected Center(String name) {
this.name = name;
this.storedAnimals = new ArrayList<>();
}
public String getName() {
return name;
}
private void setName(String name) {
this.name = name;
}
public List<Animal> getStoredAnimals() {
return storedAnimals;
}
private void setStoredAnimals(List<Animal> storedAnimals) {
this.storedAnimals = storedAnimals;
}
public void addAnimal(Animal animal){
this.storedAnimals.add(animal);
}
public void removeAnimal(Animal animal){
this.storedAnimals.remove(animal);
}
public void removeAll(){
this.setStoredAnimals(new ArrayList<>());
}
}
| [
"32268625+Deyan-Stoyanov@users.noreply.github.com"
] | 32268625+Deyan-Stoyanov@users.noreply.github.com |
d79202aece1e3a41b52a3d4ef921ca3cbe2d4fcc | d277b381b9089d05ec5bef6eca3668e756a0e059 | /temp/Platform7.1/SystemUI/src/com/android/systemui/statusbar/preferences/XmlDataBean.java | 7d1ce34795841529ed87bab2fd34eddbb871c098 | [] | no_license | Keith-WangHZ/ListViewAndRecycleView | 8e17a4fb17c13140874779656d5600af86d95366 | f9514d0de61d8454d76ed44df9be16f2248ae98e | refs/heads/master | 2020-12-14T08:52:46.554705 | 2017-07-07T06:49:19 | 2017-07-07T06:49:19 | 95,524,373 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,030 | java | package com.android.systemui.statusbar.preferences;
import java.util.ArrayList;
import java.util.HashMap;
public class XmlDataBean {
/**
*/
public HashMap<String, String> mControlmap;
/**
*/
public HashMap<String, String> mWhiteMap;
public HashMap<String, String> mWhiteMapStartWith;
public HashMap<String, String> mBlackMap;
public HashMap<String, String> mVipMap;
public HashMap<String, String> mSysMap;
public HashMap<String, String> mSystemListMap;
public HashMap<String, String> mSystemListMapStartWith;
public HashMap<String, Integer> mWhiteMapFinal;
public ArrayList<String> mWhiteMapList0;
public ArrayList<String> mWhiteMapList1;
public ArrayList<String> mWhiteMapList2;
public ArrayList<String> mWhiteMapList3;
public ArrayList<String> mWhiteMapList4;
public XmlDataBean() {
mWhiteMap = null;
mBlackMap = null;
mVipMap = null;
mSystemListMap = null;
mWhiteMapFinal = null;
mWhiteMapList0 = null;
mWhiteMapList1 = null;
mWhiteMapList2 = null;
mWhiteMapList3 = null;
}
}
| [
"wanghuazhi@yulong.com"
] | wanghuazhi@yulong.com |
cc83d83f14a042f53d08496f5104c7bc6b669d4b | 2b2dac24d1505314b7a35dc91ca06f7ee02a5e67 | /src/Algorithm/SquareRoot.java | 5400cd4a69b28aa3e8a70388758b6fecb02e5680 | [] | no_license | poojatodkar1407/Functional-Program | 410c25d104ca0561084e74fc405d6b47788b2609 | 46dbd001c28bf56068c22f170215bba71276bad5 | refs/heads/master | 2020-05-16T09:33:07.559286 | 2019-04-23T07:18:34 | 2019-04-23T07:18:34 | 182,953,218 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 220 | java | package Algorithm;
public class SquareRoot {
public static void main(String[] args) {
Double c=Double.parseDouble(args[0]);
double res=Util.Sqrt(c);
System.out.println("Square root of "+c+" is "+res);
}
}
| [
"poojatodkar124@gmail.com"
] | poojatodkar124@gmail.com |
6e2021036c5767aec7f3f3847cdb0b4224a732a6 | 994af194d62effa0d1874cd2ddbf3d9fcb348302 | /KittyWorld-Android/kitty_base/src/main/java/com/kitty/kitty_base/model/RewardModel.java | e0473e0b92d6c95af2633fd3b7d14a81ffe5daa7 | [] | no_license | gnkhandsome/KittyWorld | c5b98bb7a67517d3c3662868a9dea64ad1246cc1 | a694ee7849ef98ce469b5aa8fe6cb9a1f42b6354 | refs/heads/master | 2023-01-04T07:34:26.687044 | 2020-11-06T02:05:35 | 2020-11-06T02:05:35 | 287,684,885 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 229 | java | package com.kitty.kitty_base.model;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class RewardModel<T> {
private String id;
private String data;
private T content;
private String desc;
}
| [
"guoningkang@bonc.com.cn"
] | guoningkang@bonc.com.cn |
0845450e93c0f4482715334e5f201dd1d6edeb12 | 9ca4d8243e743cde069ec8c10450b868e4f381de | /eclipse/MPEMessagingExamples/src/fourthclient/Ball.java | 081c8beabef3f37ab270937b4c1db29ed560f2a2 | [] | no_license | radamchin/Most-Pixels-Ever | 5586b5316e50d9a9ab777f74e5f773472fc6fc02 | 4879ec6089aa81bff07242deff9764d67cb83bb6 | refs/heads/master | 2020-12-25T15:51:32.027951 | 2013-08-02T12:40:37 | 2013-08-02T12:40:37 | 2,722,175 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 930 | java | /**
* Ball class for Sound example
* <http://mostpixelsever.com>
* @author Shiffman
*/
package fourthclient;
import mpe.client.TCPClient;
import processing.core.PApplet;
public class Ball {
PApplet parent;
TCPClient client;
float x = 0; //ellipse x location
float y = 0; //ellipse y location
float xvel = 1; //x velocity
float yvel = 1; //y velocity
float gravity = 0.5f;
public Ball(PApplet _parent, TCPClient _c, float _x, float _y){
parent = _parent;
client = _c;
xvel = parent.random(10,20);
yvel = parent.random(-2,2);
x = _x;
y = _y;
}
//a simple bounce across the screen
public void calc(){
if (y > client.getMHeight()) {
yvel *= -1;
y = client.getMHeight();
}
x += xvel;
y += yvel;
yvel += gravity;
}
public void draw(){
parent.smooth();
parent.fill(0);
parent.ellipse(x,y,16,16);
}
}
| [
"daniel@shiffman.net"
] | daniel@shiffman.net |
158aca848a4455f4603379c71c5a84e01edd2fb8 | 20eb62855cb3962c2d36fda4377dfd47d82eb777 | /newEvaluatedBugs/Jsoup_11_buggy/mutated/1294/TokeniserState.java | 48c383cc41b90f7fbad59de216385ec38a86ed5a | [] | no_license | ozzydong/CapGen | 356746618848065cce4e253e5d3c381baa85044a | 0ba0321b6b1191443276021f1997833342f02515 | refs/heads/master | 2023-03-18T20:12:02.923428 | 2020-08-21T03:08:28 | 2020-08-21T03:08:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 59,396 | java | package org.jsoup.parser;
import java.util.Arrays;
/**
* States and transition activations for the Tokeniser.
*/
enum TokeniserState {
Data {
// in data state, gather characters until a character reference or tag is found
void read(Tokeniser t, CharacterReader r) {
switch (r.current()) {
case '&':
t.advanceTransition(CharacterReferenceInData);
break;
case '<':
t.advanceTransition(TagOpen);
break;
case nullChar:
t.error(this); // NOT replacement character (oddly?)
t.emit(r.consume());
break;
case eof:
t.emit(new Token.EOF());
break;
default:
String data = r.consumeData();
t.emit(data);
break;
}
}
},
CharacterReferenceInData {
// from & in data
void read(Tokeniser t, CharacterReader r) {
readCharRef(t, Data);
}
},
Rcdata {
/// handles data in title, textarea etc
void read(Tokeniser t, CharacterReader r) {
switch (r.current()) {
case '&':
t.advanceTransition(CharacterReferenceInRcdata);
break;
case '<':
t.advanceTransition(RcdataLessthanSign);
break;
case nullChar:
t.error(this);
r.advance();
t.emit(replacementChar);
break;
case eof:
t.emit(new Token.EOF());
break;
default:
String data = r.consumeToAny('&', '<', nullChar);
t.emit(data);
break;
}
}
},
CharacterReferenceInRcdata {
void read(Tokeniser t, CharacterReader r) {
readCharRef(t, Rcdata);
}
},
Rawtext {
void read(Tokeniser t, CharacterReader r) {
readData(t, r, this, RawtextLessthanSign);
}
},
ScriptData {
void read(Tokeniser t, CharacterReader r) {
readData(t, r, this, ScriptDataLessthanSign);
}
},
PLAINTEXT {
void read(Tokeniser t, CharacterReader r) {
switch (r.current()) {
case nullChar:
t.error(this);
r.advance();
t.emit(replacementChar);
break;
case eof:
t.emit(new Token.EOF());
break;
default:
String data = r.consumeTo(nullChar);
t.emit(data);
break;
}
}
},
TagOpen {
// from < in data
void read(Tokeniser t, CharacterReader r) {
switch (r.current()) {
case '!':
t.advanceTransition(MarkupDeclarationOpen);
break;
case '/':
t.advanceTransition(EndTagOpen);
break;
case '?':
t.advanceTransition(BogusComment);
break;
default:
if (r.matchesLetter()) {
t.createTagPending(true);
t.transition(TagName);
} else {
t.error(this);
t.emit('<'); // char that got us here
t.transition(Data);
}
break;
}
}
},
EndTagOpen {
void read(Tokeniser t, CharacterReader r) {
if (r.isEmpty()) {
t.eofError(this);
t.emit("</");
t.transition(Data);
} else if (r.matchesLetter()) {
t.createTagPending(false);
t.transition(TagName);
} else if (r.matches('>')) {
t.error(this);
t.advanceTransition(Data);
} else {
t.error(this);
t.advanceTransition(BogusComment);
}
}
},
TagName {
// from < or </ in data, will have start or end tag pending
void read(Tokeniser t, CharacterReader r) {
// previous TagOpen state did NOT consume, will have a letter char in current
//String tagName = r.consumeToAnySorted(tagCharsSorted).toLowerCase();
String tagName = r.consumeTagName();
t.tagPending.appendTagName(tagName);
switch (r.consume()) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BeforeAttributeName);
break;
case '/':
t.transition(SelfClosingStartTag);
break;
case '>':
t.emitTagPending();
t.transition(Data);
break;
case nullChar: // replacement
t.tagPending.appendTagName(replacementStr);
break;
case eof: // should emit pending tag?
t.eofError(this);
t.transition(Data);
// no default, as covered with above consumeToAny
}
}
},
RcdataLessthanSign {
// from < in rcdata
void read(Tokeniser t, CharacterReader r) {
if (r.matches('/')) {
t.createTempBuffer();
t.advanceTransition(RCDATAEndTagOpen);
} else if (r.matchesLetter() && t.appropriateEndTagName() != null && !r.containsIgnoreCase("</" + t.appropriateEndTagName())) {
// diverge from spec: got a start tag, but there's no appropriate end tag (</title>), so rather than
// consuming to EOF; break out here
t.tagPending = t.createTagPending(false).name(t.appropriateEndTagName());
t.emitTagPending();
r.unconsume(); // undo "<"
t.transition(Data);
} else {
t.emit("<");
t.transition(Rcdata);
}
}
},
RCDATAEndTagOpen {
void read(Tokeniser t, CharacterReader r) {
if (r.matchesLetter()) {
t.createTagPending(false);
t.tagPending.appendTagName(r.current());
t.dataBuffer.append(r.current());
t.advanceTransition(RCDATAEndTagName);
} else {
t.emit("</");
t.transition(Rcdata);
}
}
},
RCDATAEndTagName {
void read(Tokeniser t, CharacterReader r) {
if (r.matchesLetter()) {
String name = r.consumeLetterSequence();
t.tagPending.appendTagName(name);
t.dataBuffer.append(name);
return;
}
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
if (t.isAppropriateEndTagToken())
t.transition(BeforeAttributeName);
else
anythingElse(t, r);
break;
case '/':
if (t.isAppropriateEndTagToken())
t.transition(SelfClosingStartTag);
else
anythingElse(t, r);
break;
case '>':
if (t.isAppropriateEndTagToken()) {
t.emitTagPending();
t.transition(Data);
}
else
anythingElse(t, r);
break;
default:
anythingElse(t, r);
}
}
private void anythingElse(Tokeniser t, CharacterReader r) {
t.emit("</" + t.dataBuffer.toString());
r.unconsume();
t.transition(Rcdata);
}
},
RawtextLessthanSign {
void read(Tokeniser t, CharacterReader r) {
if (r.matches('/')) {
t.createTempBuffer();
t.advanceTransition(RawtextEndTagOpen);
} else {
t.emit('<');
t.transition(Rawtext);
}
}
},
RawtextEndTagOpen {
void read(Tokeniser t, CharacterReader r) {
readEndTag(t, r, RawtextEndTagName, Rawtext);
}
},
RawtextEndTagName {
void read(Tokeniser t, CharacterReader r) {
handleDataEndTag(t, r, Rawtext);
}
},
ScriptDataLessthanSign {
void read(Tokeniser t, CharacterReader r) {
switch (r.consume()) {
case '/':
t.createTempBuffer();
t.transition(ScriptDataEndTagOpen);
break;
case '!':
t.emit("<!");
t.transition(ScriptDataEscapeStart);
break;
default:
t.emit("<");
r.unconsume();
t.transition(ScriptData);
}
}
},
ScriptDataEndTagOpen {
void read(Tokeniser t, CharacterReader r) {
readEndTag(t, r, ScriptDataEndTagName, ScriptData);
}
},
ScriptDataEndTagName {
void read(Tokeniser t, CharacterReader r) {
handleDataEndTag(t, r, ScriptData);
}
},
ScriptDataEscapeStart {
void read(Tokeniser t, CharacterReader r) {
if (r.matches('-')) {
t.emit('-');
t.advanceTransition(ScriptDataEscapeStartDash);
} else {
t.transition(ScriptData);
}
}
},
ScriptDataEscapeStartDash {
void read(Tokeniser t, CharacterReader r) {
if (r.matches('-')) {
t.emit('-');
t.advanceTransition(ScriptDataEscapedDashDash);
} else {
t.transition(ScriptData);
}
}
},
ScriptDataEscaped {
void read(Tokeniser t, CharacterReader r) {
if (r.isEmpty()) {
t.eofError(this);
t.transition(Data);
return;
}
switch (r.current()) {
case '-':
t.emit('-');
t.advanceTransition(ScriptDataEscapedDash);
break;
case '<':
t.advanceTransition(ScriptDataEscapedLessthanSign);
break;
case nullChar:
t.error(this);
r.advance();
t.emit(replacementChar);
break;
default:
String data = r.consumeToAny('-', '<', nullChar);
t.emit(data);
}
}
},
ScriptDataEscapedDash {
void read(Tokeniser t, CharacterReader r) {
if (r.isEmpty()) {
t.eofError(this);
t.transition(Data);
return;
}
char c = r.consume();
switch (c) {
case '-':
t.emit(c);
t.transition(ScriptDataEscapedDashDash);
break;
case '<':
t.transition(ScriptDataEscapedLessthanSign);
break;
case nullChar:
t.error(this);
t.emit(replacementChar);
t.transition(ScriptDataEscaped);
break;
default:
t.emit(c);
t.transition(ScriptDataEscaped);
}
}
},
ScriptDataEscapedDashDash {
void read(Tokeniser t, CharacterReader r) {
if (r.isEmpty()) {
t.eofError(this);
t.transition(Data);
return;
}
char c = r.consume();
switch (c) {
case '-':
t.emit(c);
break;
case '<':
t.transition(ScriptDataEscapedLessthanSign);
break;
case '>':
t.emit(c);
t.transition(ScriptData);
break;
case nullChar:
t.error(this);
t.emit(replacementChar);
t.transition(ScriptDataEscaped);
break;
default:
t.emit(c);
t.transition(ScriptDataEscaped);
}
}
},
ScriptDataEscapedLessthanSign {
void read(Tokeniser t, CharacterReader r) {
if (r.matchesLetter()) {
t.createTempBuffer();
t.dataBuffer.append(r.current());
t.emit("<" + r.current());
t.advanceTransition(ScriptDataDoubleEscapeStart);
} else if (r.matches('/')) {
t.createTempBuffer();
t.advanceTransition(ScriptDataEscapedEndTagOpen);
} else {
t.emit('<');
t.transition(ScriptDataEscaped);
}
}
},
ScriptDataEscapedEndTagOpen {
void read(Tokeniser t, CharacterReader r) {
if (r.matchesLetter()) {
t.createTagPending(false);
t.tagPending.appendTagName(r.current());
t.dataBuffer.append(r.current());
t.advanceTransition(ScriptDataEscapedEndTagName);
} else {
t.emit("</");
t.transition(ScriptDataEscaped);
}
}
},
ScriptDataEscapedEndTagName {
void read(Tokeniser t, CharacterReader r) {
handleDataEndTag(t, r, ScriptDataEscaped);
}
},
ScriptDataDoubleEscapeStart {
void read(Tokeniser t, CharacterReader r) {
handleDataDoubleEscapeTag(t, r, ScriptDataDoubleEscaped, ScriptDataEscaped);
}
},
ScriptDataDoubleEscaped {
void read(Tokeniser t, CharacterReader r) {
char c = r.current();
switch (c) {
case '-':
t.emit(c);
t.advanceTransition(ScriptDataDoubleEscapedDash);
break;
case '<':
t.emit(c);
t.advanceTransition(ScriptDataDoubleEscapedLessthanSign);
break;
case nullChar:
t.error(this);
r.advance();
t.emit(replacementChar);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
default:
String data = r.consumeToAny('-', '<', nullChar);
t.emit(data);
}
}
},
ScriptDataDoubleEscapedDash {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '-':
t.emit(c);
t.transition(ScriptDataDoubleEscapedDashDash);
break;
case '<':
t.emit(c);
t.transition(ScriptDataDoubleEscapedLessthanSign);
break;
case nullChar:
t.error(this);
t.emit(replacementChar);
t.transition(ScriptDataDoubleEscaped);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
default:
t.emit(c);
t.transition(ScriptDataDoubleEscaped);
}
}
},
ScriptDataDoubleEscapedDashDash {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '-':
t.emit(c);
break;
case '<':
t.emit(c);
t.transition(ScriptDataDoubleEscapedLessthanSign);
break;
case '>':
t.emit(c);
t.transition(ScriptData);
break;
case nullChar:
t.error(this);
t.emit(replacementChar);
t.transition(ScriptDataDoubleEscaped);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
default:
t.emit(c);
t.transition(ScriptDataDoubleEscaped);
}
}
},
ScriptDataDoubleEscapedLessthanSign {
void read(Tokeniser t, CharacterReader r) {
if (r.matches('/')) {
t.emit('/');
t.createTempBuffer();
t.advanceTransition(ScriptDataDoubleEscapeEnd);
} else {
t.transition(ScriptDataDoubleEscaped);
}
}
},
ScriptDataDoubleEscapeEnd {
void read(Tokeniser t, CharacterReader r) {
handleDataDoubleEscapeTag(t,r, ScriptDataEscaped, ScriptDataDoubleEscaped);
}
},
BeforeAttributeName {
// from tagname <xxx
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
break; // ignore whitespace
case '/':
t.transition(SelfClosingStartTag);
break;
case '>':
t.emitTagPending();
t.transition(Data);
break;
case nullChar:
t.error(this);
t.tagPending.newAttribute();
r.unconsume();
t.transition(AttributeName);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
case '"':
case '\'':
case '<':
case '=':
t.error(this);
t.tagPending.newAttribute();
t.tagPending.appendAttributeName(c);
t.transition(AttributeName);
break;
default: // A-Z, anything else
t.tagPending.newAttribute();
r.unconsume();
t.transition(AttributeName);
}
}
},
AttributeName {
// from before attribute name
void read(Tokeniser t, CharacterReader r) {
String name = r.consumeToAnySorted(attributeNameCharsSorted);
t.tagPending.appendAttributeName(name);
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(AfterAttributeName);
break;
case '/':
t.transition(SelfClosingStartTag);
break;
case '=':
t.transition(BeforeAttributeValue);
break;
case '>':
t.emitTagPending();
t.transition(Data);
break;
case nullChar:
t.error(this);
t.tagPending.appendAttributeName(replacementChar);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
case '"':
case '\'':
case '<':
t.error(this);
t.tagPending.appendAttributeName(c);
// no default, as covered in consumeToAny
}
}
},
AfterAttributeName {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
// ignore
break;
case '/':
t.transition(SelfClosingStartTag);
break;
case '=':
t.transition(BeforeAttributeValue);
break;
case '>':
t.emitTagPending();
t.transition(Data);
break;
case nullChar:
t.error(this);
t.tagPending.appendAttributeName(replacementChar);
t.transition(AttributeName);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
case '"':
case '\'':
case '<':
t.error(this);
t.tagPending.newAttribute();
t.tagPending.appendAttributeName(c);
t.transition(AttributeName);
break;
default: // A-Z, anything else
t.tagPending.newAttribute();
r.unconsume();
t.transition(AttributeName);
}
}
},
BeforeAttributeValue {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
// ignore
break;
case '"':
t.transition(AttributeValue_doubleQuoted);
break;
case '&':
r.unconsume();
t.transition(AttributeValue_unquoted);
break;
case '\'':
t.transition(AttributeValue_singleQuoted);
break;
case nullChar:
t.error(this);
t.tagPending.appendAttributeValue(replacementChar);
t.transition(AttributeValue_unquoted);
break;
case eof:
t.eofError(this);
t.emitTagPending();
t.transition(Data);
break;
case '>':
t.error(this);
t.emitTagPending();
t.transition(Data);
break;
case '<':
case '=':
case '`':
t.error(this);
t.tagPending.appendAttributeValue(c);
t.transition(AttributeValue_unquoted);
break;
default:
r.unconsume();
t.transition(AttributeValue_unquoted);
}
}
},
AttributeValue_doubleQuoted {
void read(Tokeniser t, CharacterReader r) {
String value = r.consumeToAny(attributeDoubleValueCharsSorted);
if (value.length() > 0)
t.tagPending.appendAttributeValue(value);
else
t.tagPending.setEmptyAttributeValue();
char c = r.consume();
switch (c) {
case '"':
t.transition(AfterAttributeValue_quoted);
break;
case '&':
int[] ref = t.consumeCharacterReference('"', true);
if (ref != null)
t.tagPending.appendAttributeValue(ref);
else
t.tagPending.appendAttributeValue('&');
break;
case nullChar:
t.error(this);
t.tagPending.appendAttributeValue(replacementChar);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
// no default, handled in consume to any above
}
}
},
AttributeValue_singleQuoted {
void read(Tokeniser t, CharacterReader r) {
String value = r.consumeToAny(attributeSingleValueCharsSorted);
if (value.length() > 0)
t.tagPending.appendAttributeValue(value);
else
t.tagPending.setEmptyAttributeValue();
char c = r.consume();
org.jsoup.parser.TokeniserState.readCharRef(t, org.jsoup.parser.TokeniserState.Rcdata);
switch (c) {
case '\'':
t.transition(AfterAttributeValue_quoted);
break;
case '&':
int[] ref = t.consumeCharacterReference('\'', true);
if (ref != null)
t.tagPending.appendAttributeValue(ref);
else
t.tagPending.appendAttributeValue('&');
break;
case nullChar:
t.error(this);
t.tagPending.appendAttributeValue(replacementChar);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
// no default, handled in consume to any above
}
}
},
AttributeValue_unquoted {
void read(Tokeniser t, CharacterReader r) {
String value = r.consumeToAnySorted(attributeValueUnquoted);
if (value.length() > 0)
t.tagPending.appendAttributeValue(value);
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BeforeAttributeName);
break;
case '&':
int[] ref = t.consumeCharacterReference('>', true);
if (ref != null)
t.tagPending.appendAttributeValue(ref);
else
t.tagPending.appendAttributeValue('&');
break;
case '>':
t.emitTagPending();
t.transition(Data);
break;
case nullChar:
t.error(this);
t.tagPending.appendAttributeValue(replacementChar);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
case '"':
case '\'':
case '<':
case '=':
case '`':
t.error(this);
t.tagPending.appendAttributeValue(c);
break;
// no default, handled in consume to any above
}
}
},
// CharacterReferenceInAttributeValue state handled inline
AfterAttributeValue_quoted {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BeforeAttributeName);
break;
case '/':
t.transition(SelfClosingStartTag);
break;
case '>':
t.emitTagPending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
default:
t.error(this);
r.unconsume();
t.transition(BeforeAttributeName);
}
}
},
SelfClosingStartTag {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '>':
t.tagPending.selfClosing = true;
t.emitTagPending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.transition(Data);
break;
default:
t.error(this);
t.transition(BeforeAttributeName);
}
}
},
BogusComment {
void read(Tokeniser t, CharacterReader r) {
// todo: handle bogus comment starting from eof. when does that trigger?
// rewind to capture character that lead us here
r.unconsume();
Token.Comment comment = new Token.Comment();
comment.bogus = true;
comment.data.append(r.consumeTo('>'));
// todo: replace nullChar with replaceChar
t.emit(comment);
t.advanceTransition(Data);
}
},
MarkupDeclarationOpen {
void read(Tokeniser t, CharacterReader r) {
if (r.matchConsume("--")) {
t.createCommentPending();
t.transition(CommentStart);
} else if (r.matchConsumeIgnoreCase("DOCTYPE")) {
t.transition(Doctype);
} else if (r.matchConsume("[CDATA[")) {
// todo: should actually check current namepspace, and only non-html allows cdata. until namespace
// is implemented properly, keep handling as cdata
//} else if (!t.currentNodeInHtmlNS() && r.matchConsume("[CDATA[")) {
t.transition(CdataSection);
} else {
t.error(this);
t.advanceTransition(BogusComment); // advance so this character gets in bogus comment data's rewind
}
}
},
CommentStart {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '-':
t.transition(CommentStartDash);
break;
case nullChar:
t.error(this);
t.commentPending.data.append(replacementChar);
t.transition(Comment);
break;
case '>':
t.error(this);
t.emitCommentPending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.emitCommentPending();
t.transition(Data);
break;
default:
t.commentPending.data.append(c);
t.transition(Comment);
}
}
},
CommentStartDash {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '-':
t.transition(CommentStartDash);
break;
case nullChar:
t.error(this);
t.commentPending.data.append(replacementChar);
t.transition(Comment);
break;
case '>':
t.error(this);
t.emitCommentPending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.emitCommentPending();
t.transition(Data);
break;
default:
t.commentPending.data.append(c);
t.transition(Comment);
}
}
},
Comment {
void read(Tokeniser t, CharacterReader r) {
char c = r.current();
switch (c) {
case '-':
t.advanceTransition(CommentEndDash);
break;
case nullChar:
t.error(this);
r.advance();
t.commentPending.data.append(replacementChar);
break;
case eof:
t.eofError(this);
t.emitCommentPending();
t.transition(Data);
break;
default:
t.commentPending.data.append(r.consumeToAny('-', nullChar));
}
}
},
CommentEndDash {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '-':
t.transition(CommentEnd);
break;
case nullChar:
t.error(this);
t.commentPending.data.append('-').append(replacementChar);
t.transition(Comment);
break;
case eof:
t.eofError(this);
t.emitCommentPending();
t.transition(Data);
break;
default:
t.commentPending.data.append('-').append(c);
t.transition(Comment);
}
}
},
CommentEnd {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '>':
t.emitCommentPending();
t.transition(Data);
break;
case nullChar:
t.error(this);
t.commentPending.data.append("--").append(replacementChar);
t.transition(Comment);
break;
case '!':
t.error(this);
t.transition(CommentEndBang);
break;
case '-':
t.error(this);
t.commentPending.data.append('-');
break;
case eof:
t.eofError(this);
t.emitCommentPending();
t.transition(Data);
break;
default:
t.error(this);
t.commentPending.data.append("--").append(c);
t.transition(Comment);
}
}
},
CommentEndBang {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '-':
t.commentPending.data.append("--!");
t.transition(CommentEndDash);
break;
case '>':
t.emitCommentPending();
t.transition(Data);
break;
case nullChar:
t.error(this);
t.commentPending.data.append("--!").append(replacementChar);
t.transition(Comment);
break;
case eof:
t.eofError(this);
t.emitCommentPending();
t.transition(Data);
break;
default:
t.commentPending.data.append("--!").append(c);
t.transition(Comment);
}
}
},
Doctype {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BeforeDoctypeName);
break;
case eof:
t.eofError(this);
// note: fall through to > case
case '>': // catch invalid <!DOCTYPE>
t.error(this);
t.createDoctypePending();
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.transition(BeforeDoctypeName);
}
}
},
BeforeDoctypeName {
void read(Tokeniser t, CharacterReader r) {
if (r.matchesLetter()) {
t.createDoctypePending();
t.transition(DoctypeName);
return;
}
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
break; // ignore whitespace
case nullChar:
t.error(this);
t.createDoctypePending();
t.doctypePending.name.append(replacementChar);
t.transition(DoctypeName);
break;
case eof:
t.eofError(this);
t.createDoctypePending();
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.createDoctypePending();
t.doctypePending.name.append(c);
t.transition(DoctypeName);
}
}
},
DoctypeName {
void read(Tokeniser t, CharacterReader r) {
if (r.matchesLetter()) {
String name = r.consumeLetterSequence();
t.doctypePending.name.append(name);
return;
}
char c = r.consume();
switch (c) {
case '>':
t.emitDoctypePending();
t.transition(Data);
break;
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(AfterDoctypeName);
break;
case nullChar:
t.error(this);
t.doctypePending.name.append(replacementChar);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.doctypePending.name.append(c);
}
}
},
AfterDoctypeName {
void read(Tokeniser t, CharacterReader r) {
if (r.isEmpty()) {
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
return;
}
if (r.matchesAny('\t', '\n', '\r', '\f', ' '))
r.advance(); // ignore whitespace
else if (r.matches('>')) {
t.emitDoctypePending();
t.advanceTransition(Data);
} else if (r.matchConsumeIgnoreCase("PUBLIC")) {
t.transition(AfterDoctypePublicKeyword);
} else if (r.matchConsumeIgnoreCase("SYSTEM")) {
t.transition(AfterDoctypeSystemKeyword);
} else {
t.error(this);
t.doctypePending.forceQuirks = true;
t.advanceTransition(BogusDoctype);
}
}
},
AfterDoctypePublicKeyword {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BeforeDoctypePublicIdentifier);
break;
case '"':
t.error(this);
// set public id to empty string
t.transition(DoctypePublicIdentifier_doubleQuoted);
break;
case '\'':
t.error(this);
// set public id to empty string
t.transition(DoctypePublicIdentifier_singleQuoted);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.doctypePending.forceQuirks = true;
t.transition(BogusDoctype);
}
}
},
BeforeDoctypePublicIdentifier {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
break;
case '"':
// set public id to empty string
t.transition(DoctypePublicIdentifier_doubleQuoted);
break;
case '\'':
// set public id to empty string
t.transition(DoctypePublicIdentifier_singleQuoted);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.doctypePending.forceQuirks = true;
t.transition(BogusDoctype);
}
}
},
DoctypePublicIdentifier_doubleQuoted {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '"':
t.transition(AfterDoctypePublicIdentifier);
break;
case nullChar:
t.error(this);
t.doctypePending.publicIdentifier.append(replacementChar);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.doctypePending.publicIdentifier.append(c);
}
}
},
DoctypePublicIdentifier_singleQuoted {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\'':
t.transition(AfterDoctypePublicIdentifier);
break;
case nullChar:
t.error(this);
t.doctypePending.publicIdentifier.append(replacementChar);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.doctypePending.publicIdentifier.append(c);
}
}
},
AfterDoctypePublicIdentifier {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BetweenDoctypePublicAndSystemIdentifiers);
break;
case '>':
t.emitDoctypePending();
t.transition(Data);
break;
case '"':
t.error(this);
// system id empty
t.transition(DoctypeSystemIdentifier_doubleQuoted);
break;
case '\'':
t.error(this);
// system id empty
t.transition(DoctypeSystemIdentifier_singleQuoted);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.doctypePending.forceQuirks = true;
t.transition(BogusDoctype);
}
}
},
BetweenDoctypePublicAndSystemIdentifiers {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
break;
case '>':
t.emitDoctypePending();
t.transition(Data);
break;
case '"':
t.error(this);
// system id empty
t.transition(DoctypeSystemIdentifier_doubleQuoted);
break;
case '\'':
t.error(this);
// system id empty
t.transition(DoctypeSystemIdentifier_singleQuoted);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.doctypePending.forceQuirks = true;
t.transition(BogusDoctype);
}
}
},
AfterDoctypeSystemKeyword {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BeforeDoctypeSystemIdentifier);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case '"':
t.error(this);
// system id empty
t.transition(DoctypeSystemIdentifier_doubleQuoted);
break;
case '\'':
t.error(this);
// system id empty
t.transition(DoctypeSystemIdentifier_singleQuoted);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
}
}
},
BeforeDoctypeSystemIdentifier {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
break;
case '"':
// set system id to empty string
t.transition(DoctypeSystemIdentifier_doubleQuoted);
break;
case '\'':
// set public id to empty string
t.transition(DoctypeSystemIdentifier_singleQuoted);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.doctypePending.forceQuirks = true;
t.transition(BogusDoctype);
}
}
},
DoctypeSystemIdentifier_doubleQuoted {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '"':
t.transition(AfterDoctypeSystemIdentifier);
break;
case nullChar:
t.error(this);
t.doctypePending.systemIdentifier.append(replacementChar);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.doctypePending.systemIdentifier.append(c);
}
}
},
DoctypeSystemIdentifier_singleQuoted {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\'':
t.transition(AfterDoctypeSystemIdentifier);
break;
case nullChar:
t.error(this);
t.doctypePending.systemIdentifier.append(replacementChar);
break;
case '>':
t.error(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.doctypePending.systemIdentifier.append(c);
}
}
},
AfterDoctypeSystemIdentifier {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
break;
case '>':
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.eofError(this);
t.doctypePending.forceQuirks = true;
t.emitDoctypePending();
t.transition(Data);
break;
default:
t.error(this);
t.transition(BogusDoctype);
// NOT force quirks
}
}
},
BogusDoctype {
void read(Tokeniser t, CharacterReader r) {
char c = r.consume();
switch (c) {
case '>':
t.emitDoctypePending();
t.transition(Data);
break;
case eof:
t.emitDoctypePending();
t.transition(Data);
break;
default:
// ignore char
break;
}
}
},
CdataSection {
void read(Tokeniser t, CharacterReader r) {
String data = r.consumeTo("]]>");
t.emit(data);
r.matchConsume("]]>");
t.transition(Data);
}
};
abstract void read(Tokeniser t, CharacterReader r);
static final char nullChar = '\u0000';
private static final char[] attributeSingleValueCharsSorted = new char[]{'\'', '&', nullChar};
private static final char[] attributeDoubleValueCharsSorted = new char[]{'"', '&', nullChar};
private static final char[] attributeNameCharsSorted = new char[]{'\t', '\n', '\r', '\f', ' ', '/', '=', '>', nullChar, '"', '\'', '<'};
private static final char[] attributeValueUnquoted = new char[]{'\t', '\n', '\r', '\f', ' ', '&', '>', nullChar, '"', '\'', '<', '=', '`'};
private static final char replacementChar = Tokeniser.replacementChar;
private static final String replacementStr = String.valueOf(Tokeniser.replacementChar);
private static final char eof = CharacterReader.EOF;
static {
Arrays.sort(attributeSingleValueCharsSorted);
Arrays.sort(attributeDoubleValueCharsSorted);
Arrays.sort(attributeNameCharsSorted);
Arrays.sort(attributeValueUnquoted);
}
/**
* Handles RawtextEndTagName, ScriptDataEndTagName, and ScriptDataEscapedEndTagName. Same body impl, just
* different else exit transitions.
*/
private static void handleDataEndTag(Tokeniser t, CharacterReader r, TokeniserState elseTransition) {
if (r.matchesLetter()) {
String name = r.consumeLetterSequence();
t.tagPending.appendTagName(name);
t.dataBuffer.append(name);
return;
}
boolean needsExitTransition = false;
if (t.isAppropriateEndTagToken() && !r.isEmpty()) {
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
t.transition(BeforeAttributeName);
break;
case '/':
t.transition(SelfClosingStartTag);
break;
case '>':
t.emitTagPending();
t.transition(Data);
break;
default:
t.dataBuffer.append(c);
needsExitTransition = true;
}
} else {
needsExitTransition = true;
}
if (needsExitTransition) {
t.emit("</" + t.dataBuffer.toString());
t.transition(elseTransition);
}
}
private static void readData(Tokeniser t, CharacterReader r, TokeniserState current, TokeniserState advance) {
switch (r.current()) {
case '<':
t.advanceTransition(advance);
break;
case nullChar:
t.error(current);
r.advance();
t.emit(replacementChar);
break;
case eof:
t.emit(new Token.EOF());
break;
default:
String data = r.consumeToAny('<', nullChar);
t.emit(data);
break;
}
}
private static void readCharRef(Tokeniser t, TokeniserState advance) {
int[] c = t.consumeCharacterReference(null, false);
if (c == null)
t.emit('&');
else
t.emit(c);
t.transition(advance);
}
private static void readEndTag(Tokeniser t, CharacterReader r, TokeniserState a, TokeniserState b) {
if (r.matchesLetter()) {
t.createTagPending(false);
t.transition(a);
} else {
t.emit("</");
t.transition(b);
}
}
private static void handleDataDoubleEscapeTag(Tokeniser t, CharacterReader r, TokeniserState primary, TokeniserState fallback) {
if (r.matchesLetter()) {
String name = r.consumeLetterSequence();
t.dataBuffer.append(name);
t.emit(name);
return;
}
char c = r.consume();
switch (c) {
case '\t':
case '\n':
case '\r':
case '\f':
case ' ':
case '/':
case '>':
if (t.dataBuffer.toString().equals("script"))
t.transition(primary);
else
t.transition(fallback);
t.emit(c);
break;
default:
r.unconsume();
t.transition(fallback);
}
}
}
| [
"justinwm@163.com"
] | justinwm@163.com |
05bb37994d812d3a23b27d6d24c0d76624d0f492 | 7c671f79781238d71653023fcc8ed629ee3d29f7 | /WebServis/KutuphaneService/src/com/android/Kitap_Service.java | d508f5923cd3e38f9cbd833e3cc20754ca98068c | [] | no_license | akarakaya/DigitalLibrary | e4d892fbfa8414d6a14b0d1c1c20528b1d4e26c0 | 0d012a12d8b8b6305568e7e898dab874fd53b886 | refs/heads/master | 2020-07-15T14:03:33.759051 | 2016-08-24T09:15:22 | 2016-08-24T09:15:22 | 66,210,548 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,729 | java | package com.android;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
@Path("/kitap_service")
public class Kitap_Service {
@GET
@Path("/listele")
@Produces(MediaType.APPLICATION_JSON)
public String kitapListele (@QueryParam("kutuphaneId") String kutuphaneId) {
String komut = "SELECT * FROM kitap WHERE kutuphid="+Integer.parseInt(kutuphaneId);
String response = "";
List<Kitap> kitaplar = new ArrayList<Kitap>();
Connection myConnec;
PreparedStatement preStat;
ResultSet result;
DBConnection mybag = new DBConnection();
myConnec = mybag.setConnection();
try {
preStat = myConnec.prepareStatement(komut);
result = preStat.executeQuery();
while (result.next()) {
int id = result.getInt("kitapid");
int kutuphid = result.getInt("kutuphid");
String kitap_adi = result.getString("kitap_adi");
int sayfa_sayisi = result.getInt("sayfa_sayisi");
String ozellik = result.getString("ozellikleri");
String yazarlar = result.getString("yazarlari");
String isbn = result.getString("isbn");
int adet = result.getInt("adedi");
int suanki_adet = result.getInt("suanki_adedi");
String ekitap_path = result.getString("ekitap");
Kitap a = new Kitap(id, kutuphid,kitap_adi, sayfa_sayisi, ozellik, yazarlar, isbn, adet, suanki_adet, ekitap_path);
kitaplar.add(a);
response = Utitlity.kitapJSON(kitaplar, true);
}
}catch (Exception e) {
e.printStackTrace();
}
System.out.println(response);
return response;
}
@GET
@Path("/kirala")
@Produces(MediaType.APPLICATION_JSON)
public String kirala(@QueryParam("kitapId") String kitapId,@QueryParam("kullaniciid") String kullaniciId) {
String response = "";
String komut = "SELECT * from kitap WHERE kitapid="+Integer.parseInt(kitapId);
Connection myConnec;
PreparedStatement preStat;
ResultSet result;
DBConnection mybag = new DBConnection();
myConnec = mybag.setConnection();
Kitap kitap = null;
try {
preStat = myConnec.prepareStatement(komut);
result = preStat.executeQuery();
while (result.next()) {
int id = result.getInt("kitapid");
int kutuphid = result.getInt("kutuphid");
String kitap_adi = result.getString("kitap_adi");
int sayfa_sayisi = result.getInt("sayfa_sayisi");
String ozellik = result.getString("ozellikleri");
String yazarlar = result.getString("yazarlari");
String isbn = result.getString("isbn");
int adet = result.getInt("adedi");
int suanki_adet = result.getInt("suanki_adedi");
String ekitap_path = result.getString("ekitap");
kitap = new Kitap(id, kutuphid,kitap_adi, sayfa_sayisi, ozellik, yazarlar, isbn, adet, suanki_adet, ekitap_path);
}
}catch (Exception e) {
e.printStackTrace();
}
if (kitap.suanki_adet > 0) {
Calendar calendar = Calendar.getInstance();
Timestamp kiralamatarih = new Timestamp(calendar.getTime().getTime());
komut = "UPDATE kitap SET suanki_adedi="+(kitap.suanki_adet-1)+" WHERE kitapid="
+kitap.id;
String komut2 = "INSERT INTO kiralama (kullaniciid, kitapid, kontrol, sure_uzatma, "
+ "kiralama_tarihi) VALUES (?,?,?,?,?)";
String kiralamasorgu = "SELECT kiralamaid FROM kiralama WHERE kullaniciid="+Integer.parseInt(kullaniciId)+
" AND kitapid="+Integer.parseInt(kitapId)+" AND kiralama_tarihi=?"+
" AND kontrol=1";
try {
preStat = myConnec.prepareStatement(komut);
preStat.executeUpdate();
preStat = myConnec.prepareStatement(komut2);
preStat.setInt(1, Integer.parseInt(kullaniciId));
preStat.setInt(2, Integer.parseInt(kitapId));
preStat.setInt(3, 1);
preStat.setInt(4, 0);
preStat.setTimestamp(5, kiralamatarih);
preStat.execute();
preStat = myConnec.prepareStatement(kiralamasorgu);
preStat.setTimestamp(1, kiralamatarih);
result = preStat.executeQuery();
while (result.next()) {
int kiralamaId = result.getInt("kiralamaid");
response = Utitlity.kiralaJSON(kiralamaId,true);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
response = Utitlity.kiralaJSON(0,false);
}
}
else {
response = Utitlity.kiralaJSON(0,false);
}
return response;
}
@GET
@Path("/iade")
@Produces(MediaType.APPLICATION_JSON)
public String iade(@QueryParam("kiralamaId") String kiralamaId) {
String response = "";
String komut = "SELECT * FROM kiralama WHERE kiralamaid="+Integer.parseInt(kiralamaId);
Connection myConnec;
PreparedStatement preStat;
ResultSet result;
DBConnection mybag = new DBConnection();
myConnec = mybag.setConnection();
try {
preStat = myConnec.prepareStatement(komut);
result = preStat.executeQuery();
int id = 0;
while (result.next()) {
id = result.getInt("kitapid");
}
komut = "SELECT * FROM kitap WHERE kitapid="+id;
preStat = myConnec.prepareStatement(komut);
result = preStat.executeQuery();
Kitap kitap = null;
while (result.next()) {
id = result.getInt("kitapid");
int kutuphid = result.getInt("kutuphid");
String kitap_adi = result.getString("kitap_adi");
int sayfa_sayisi = result.getInt("sayfa_sayisi");
String ozellik = result.getString("ozellikleri");
String yazarlar = result.getString("yazarlari");
String isbn = result.getString("isbn");
int adet = result.getInt("adedi");
int suanki_adet = result.getInt("suanki_adedi");
String ekitap_path = result.getString("ekitap");
kitap = new Kitap(id, kutuphid,kitap_adi, sayfa_sayisi, ozellik, yazarlar, isbn, adet, suanki_adet, ekitap_path);
}
komut = "UPDATE kitap SET suanki_adedi="+(kitap.suanki_adet+1)+" WHERE kitapid="+kitap.getId();
preStat = myConnec.prepareStatement(komut);
preStat.executeUpdate();
komut = "UPDATE kiralama SET kontrol=0 WHERE kiralamaid="+Integer.parseInt(kiralamaId);
preStat = myConnec.prepareStatement(komut);
preStat.executeUpdate();
response = Utitlity.iadeJSON(true);
} catch (SQLException e) {
// TODO Auto-generated catch block
response = Utitlity.iadeJSON(false);
e.printStackTrace();
}
return response;
}
}
| [
"aykut.karakaya@bil.omu.edu.tr"
] | aykut.karakaya@bil.omu.edu.tr |
b09f905fdf93ac4476ac7ff9f0b5972ca67e0856 | f34b6d8786eb61f8cdebc8b3c7f0b51c9ed4d096 | /app/src/main/java/com/codepath/apps/restclienttemplate/TimeFormatter.java | 85674274ad61d2c06e24232623c69b690f9d5981 | [
"MIT",
"Apache-2.0"
] | permissive | ifsfiq/SimpleTweet | f0540604c2aa4d6cd7e5589db05f27822b79bff5 | 50f330487ca3a3fc23a62d8b569619923683e667 | refs/heads/master | 2023-08-15T14:55:45.150610 | 2021-10-02T04:35:35 | 2021-10-02T04:35:35 | 410,347,627 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,287 | java | package com.codepath.apps.restclienttemplate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
/**
* Given a date String of the format given by the Twitter API, returns a display-formatted
* String representing the relative time difference, e.g. "2m", "6d", "23 May", "1 Jan 14"
* depending on how great the time difference between now and the given date is.
* This, as of 2016-06-29, matches the behavior of the official Twitter app.
*/
public class TimeFormatter {
public static String getTimeDifference(String rawJsonDate) {
String time = "";
String twitterFormat = "EEE MMM dd HH:mm:ss ZZZZZ yyyy";
SimpleDateFormat format = new SimpleDateFormat(twitterFormat, Locale.ENGLISH);
format.setLenient(true);
try {
long diff = (System.currentTimeMillis() - format.parse(rawJsonDate).getTime()) / 1000;
if (diff < 5)
time = "Just now";
else if (diff < 60)
time = String.format(Locale.ENGLISH, "%ds",diff);
else if (diff < 60 * 60)
time = String.format(Locale.ENGLISH, "%dm", diff / 60);
else if (diff < 60 * 60 * 24)
time = String.format(Locale.ENGLISH, "%dh", diff / (60 * 60));
else if (diff < 60 * 60 * 24 * 30)
time = String.format(Locale.ENGLISH, "%dd", diff / (60 * 60 * 24));
else {
Calendar now = Calendar.getInstance();
Calendar then = Calendar.getInstance();
then.setTime(format.parse(rawJsonDate));
if (now.get(Calendar.YEAR) == then.get(Calendar.YEAR)) {
time = String.valueOf(then.get(Calendar.DAY_OF_MONTH)) + " "
+ then.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US);
} else {
time = String.valueOf(then.get(Calendar.DAY_OF_MONTH)) + " "
+ then.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US)
+ " " + String.valueOf(then.get(Calendar.YEAR) - 2000);
}
}
} catch (ParseException e) {
e.printStackTrace();
}
return time;
}
/**
* Given a date String of the format given by the Twitter API, returns a display-formatted
* String of the absolute date of the form "30 Jun 16".
* This, as of 2016-06-30, matches the behavior of the official Twitter app.
*/
public static String getTimeStamp(String rawJsonDate) {
String time = "";
String twitterFormat = "EEE MMM dd HH:mm:ss ZZZZZ yyyy";
SimpleDateFormat format = new SimpleDateFormat(twitterFormat, Locale.ENGLISH);
format.setLenient(true);
try {
Calendar then = Calendar.getInstance();
then.setTime(format.parse(rawJsonDate));
Date date = then.getTime();
SimpleDateFormat format1 = new SimpleDateFormat("h:mm a \u00b7 dd MMM yy");
time = format1.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
return time;
}
}
| [
"faruiq@gmail.com"
] | faruiq@gmail.com |
7ede5d285bb08f6a36584a42de3e36264bd6e22a | 1a33e46508366079fdda9cc3f61d8492ba87a0ca | /app/src/main/java/com/example/ex_2_layouts/MainActivity.java | 097f1d8fc0ff48d6fea61e7faacafc0a890593f5 | [] | no_license | Keelerak/Ex_2_layouts | 4f3861abe019dc6e13368bf9844e8bfd36b5afae | ea9253a9a15bab09ab1f448b45f7f725a6736786 | refs/heads/master | 2020-09-09T02:34:29.126234 | 2019-11-13T00:34:29 | 2019-11-13T00:34:29 | 221,319,663 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 338 | java | package com.example.ex_2_layouts;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
| [
"potashin.a@naterezzi.com"
] | potashin.a@naterezzi.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.