blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bf9c48fa29f9b9bb04a571b7921316708a0527de | dfca985e3fe34291184550550d4e77346e526f24 | /src/main/java/manageproject/logic/impl/TeacherLogicImpl.java | 51893444b6c378d873faca1dac361618632d1c33 | [] | no_license | manlydevil/manageproject | ad6061b25b6d1f66b3092bd94fcecc9e0ea7555d | 5d65a5db7532ce8919572be6714bc377827ec8d8 | refs/heads/master | 2021-01-22T22:03:42.223468 | 2019-01-17T07:53:44 | 2019-01-17T07:53:49 | 92,755,050 | 0 | 0 | null | 2017-06-28T10:09:15 | 2017-05-29T16:04:30 | Java | UTF-8 | Java | false | false | 6,618 | java | /**Copyright(C) 2017
*TeacherLogicImpl.java, Mar 18, 2017 [Nguyễn Hưng Thuận]
*/
package manageproject.logic.impl;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import manageproject.dao.TeacherDao;
import manageproject.entities.DegreeBean;
import manageproject.entities.TeacherBean;
import manageproject.entities.formbean.AccountInfor;
import manageproject.entities.formbean.InforSearchFormBean;
import manageproject.entities.formbean.InforSearchTeacherBean;
import manageproject.entities.formbean.ProjectInforBean;
import manageproject.entities.formbean.StudentFormBean;
import manageproject.entities.formbean.TeacherFormBean;
import manageproject.logic.TeacherLogic;
import manageproject.utils.Common;
/**
* @author DELL
*
*/
@Repository
public class TeacherLogicImpl implements TeacherLogic {
@Autowired
private TeacherDao teacherDao;
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getAllTeacher()
*/
public List<TeacherFormBean> getAllTeacher() {
List<TeacherFormBean> list = teacherDao.getAllTeacher();
for(TeacherFormBean teacher : list) {
teacher.setTeacherName(teacher.getDegreeName()+"."+teacher.getTeacherName());
}
TeacherFormBean bean = new TeacherFormBean(0, "Hãy chọn giảng viên");
list.add(0,bean);
return list;
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getListTeacher(manageproject.entities.formbean.InforSearchTeacherBean, int, int)
*/
public List<TeacherFormBean> getListTeacher(InforSearchTeacherBean inforSearch, int limit, int offset) {
return teacherDao.getListTeacher(inforSearch.getTeacherName(), limit, offset);
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getTotalRecords(manageproject.entities.formbean.InforSearchTeacherBean)
*/
public int getTotalRecords(InforSearchTeacherBean inforSearch) {
return teacherDao.getTotalRecords(inforSearch.getTeacherName());
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#deleteTeacher(int)
*/
public boolean deleteTeacher(int teacherID) {
try {
return teacherDao.deleteTeacher(teacherID);
} catch(Exception ex) {
ex.printStackTrace();
return false;
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getTeacherByID(int)
*/
public TeacherFormBean getTeacherByID(int teacherID){
try {
TeacherBean teacherBean = teacherDao.getTeacherByID(teacherID);
TeacherFormBean formBean = new TeacherFormBean();
PropertyUtils.copyProperties(formBean, teacherBean);
formBean.setDegreeID(teacherBean.getDegree().getDegreeID());
formBean.setBirthday(Common.formatDate(formBean.getBirthday()));
return formBean;
} catch(Exception ex) {
ex.printStackTrace();
return new TeacherFormBean();
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#insertOrUpdate(manageproject.entities.formbean.TeacherFormBean)
*/
public boolean insertOrUpdate(TeacherFormBean teacherFormBean) {
try {
TeacherBean teacherBean = new TeacherBean();
PropertyUtils.copyProperties(teacherBean, teacherFormBean);
DegreeBean degree = new DegreeBean(teacherFormBean.getDegreeID(), teacherFormBean.getDegreeName());
teacherBean.setBirthday(Common.convertDateHQL(teacherBean.getBirthday()));
teacherBean.setDegree(degree);
return teacherDao.insertOrUpdate(teacherBean);
} catch(Exception ex) {
ex.printStackTrace();
return false;
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getListDegree()
*/
public List<DegreeBean> getListDegree() {
try {
List<DegreeBean> list = teacherDao.getListDegree();
DegreeBean degreeBean = new DegreeBean(0, "Hãy chọn học vị");
list.add(0, degreeBean);
return list;
} catch(Exception ex) {
ex.printStackTrace();
return new ArrayList<DegreeBean>();
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getListStudentAssigned(int, java.lang.String, java.lang.String, int, int, int, int)
*/
public List<ProjectInforBean> getListStudentInstruction(int teacherID, InforSearchFormBean student, int limit, int offset) {
try {
return teacherDao.getListStudentInstruction(teacherID, student.getStudentNumber(), student.getName(), Integer.parseInt(student.getTermID()), Integer.parseInt(student.getEduProgramID()), limit, offset);
} catch(Exception ex) {
ex.printStackTrace();
return new ArrayList<ProjectInforBean>();
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getTotalStudent(int, java.lang.String, java.lang.String, int, int)
*/
public int getTotalStudent(int teacherID, InforSearchFormBean student) {
try {
return teacherDao.getTotalStudent(teacherID, student.getStudentNumber(), student.getName(), Integer.parseInt(student.getTermID()), Integer.parseInt(student.getEduProgramID()));
} catch(Exception ex) {
ex.printStackTrace();
return 0;
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#checkExistedAccountInfor(java.lang.String, java.lang.String)
*/
public boolean checkExistedAccountInfor(AccountInfor accountInfor) {
try{
return teacherDao.checkExistedAccountInfor(accountInfor.getUserName(), Common.encryptMD5(accountInfor.getPassword()));
} catch(Exception ex) {
ex.printStackTrace();
return false;
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getTeacherIDByUserName(java.lang.String)
*/
public int getTeacherIDByUserName(String userName) {
try{
return teacherDao.getTeacherIDByUserName(userName);
} catch(Exception ex) {
ex.printStackTrace();
return 0;
}
}
/*
* (non-Javadoc)
* @see manageproject.logic.TeacherLogic#getTeacherIDByName(java.lang.String)
*/
public String getTeacherIDByName(String name) {
try {
for(TeacherFormBean bean : teacherDao.getAllTeacher()) {
if(Common.standardizedString(name).equals(Common.standardizedString(bean.getTeacherName()))) {
return String.valueOf(bean.getTeacherID());
}
}
return "";
} catch(Exception ex) {
ex.printStackTrace();
return "";
}
}
public List<ProjectInforBean> getListStudentReview(int teacherID, InforSearchFormBean student) {
try {
return teacherDao.getListStudentReview(teacherID, student.getStudentNumber(), student.getName(), Integer.parseInt(student.getTermID()), Integer.parseInt(student.getEduProgramID()));
} catch(Exception ex) {
ex.printStackTrace();
return new ArrayList<ProjectInforBean>();
}
}
}
| [
"[email protected]"
] | |
debaadf95c7ade47f7bc6fda898085b8a386f244 | fd97c933db14c4dceed9ad98e712800d04478cd1 | /app/src/androidTest/java/com/xianjiu/www/togithubproject/ExampleInstrumentedTest.java | 628c15b189ad4239bf381d766db1243de6dc13b3 | [] | no_license | MingfangLu/ToGithubPro | 8de09fb5a9165c03e37f7f78cb558bdbc4d09139 | c95c239115dd5d5af537e851487ace61c819af51 | refs/heads/master | 2021-01-01T06:43:39.538155 | 2018-01-05T05:58:54 | 2018-01-05T05:58:54 | 97,498,062 | 0 | 0 | null | 2017-07-18T09:42:50 | 2017-07-17T16:35:04 | Java | UTF-8 | Java | false | false | 766 | java | package com.xianjiu.www.togithubproject;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.xianjiu.www.togithubproject", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
807f84043edd1dfc8e19a1684bf8ebe6a54e7498 | 1f303c9115d2b6c4d068f7efe6bc1390b7ee8337 | /app/src/main/java/br/com/ericksprengel/android/baking/data/source/RecipesRepository.java | 4eecfc4852acf2900eeb6ed20477eff06e33be1b | [] | no_license | ericksprengel/udacity-baking | 5023fe3c081dd893cfbf632c6e5c6aac2cb371ed | 078c6e1e2eadb74a7af7c1e98dfdb0c794e605c1 | refs/heads/master | 2021-09-04T04:48:02.251343 | 2018-01-16T01:08:36 | 2018-01-16T01:08:36 | 114,746,780 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,050 | java | /*
* Copyright 2016, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package br.com.ericksprengel.android.baking.data.source;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import br.com.ericksprengel.android.baking.data.Ingredient;
import br.com.ericksprengel.android.baking.data.Recipe;
import br.com.ericksprengel.android.baking.data.Step;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Implementation to load recipes from the data sources into a cache.
*
*/
public class RecipesRepository implements RecipesDataSource {
private volatile static RecipesRepository INSTANCE = null;
private final RecipesDataSource mRecipesRemoteDataSource;
private final RecipesDataSource mRecipesLocalDataSource;
/**
* Cache for load Recipes in memory.
*/
private Map<Integer, Recipe> mCachedRecipes;
private Map<Integer, List<Step>> mCachedStepsByRecipe;
private Map<Integer, Map<Integer, Step>> mCachedSteps; // step primary key is recipeId and stepId
private Map<Integer, List<Ingredient>> mCachedIngredientsByRecipe;
/**
* Marks the cache as invalid, to force an update the next time data is requested.
*/
private boolean mCacheIsDirty = false;
// Prevent direct instantiation.
private RecipesRepository(@NonNull RecipesDataSource recipesRemoteDataSource,
@NonNull RecipesDataSource recipesLocalDataSource) {
mRecipesRemoteDataSource = checkNotNull(recipesRemoteDataSource);
mRecipesLocalDataSource = checkNotNull(recipesLocalDataSource);
}
/**
* Returns the single instance of this class, creating it if necessary.
*
* @param recipesRemoteDataSource the backend data source.
* @return the {@link RecipesRepository} instance
*/
public static RecipesRepository getInstance(RecipesDataSource recipesRemoteDataSource, RecipesDataSource recipesLocalDataSource) {
if (INSTANCE == null) {
synchronized (RecipesRepository.class) {
if (INSTANCE == null) {
INSTANCE = new RecipesRepository(recipesRemoteDataSource, recipesLocalDataSource);
}
}
}
return INSTANCE;
}
/**
* Used to force {@link #getInstance(RecipesDataSource, RecipesDataSource)} to create a new instance
* next time it's called.
*/
public static void destroyInstance() {
INSTANCE = null;
}
/**
* Gets recipes from cache or remote data source, whichever is
* available first.
* <p>
* Note: {@link LoadRecipesCallback#onDataNotAvailable(int errorCode, String errorMessage)} is fired if all data sources fail to
* get the data.
*/
@Override
public boolean getRecipes(@NonNull final LoadRecipesCallback callback) {
checkNotNull(callback);
// Respond immediately with cache if available and not dirty
if (mCachedRecipes != null && !mCacheIsDirty) {
callback.onRecipesLoaded(new ArrayList<>(mCachedRecipes.values()));
return true;
}
if (mCacheIsDirty) {
// If the cache is dirty we need to fetch new data from the network.
getRecipesFromRemoteDataSource(callback);
} else {
// Query the local storage if available. If not, query the network.
mRecipesLocalDataSource.getRecipes(new LoadRecipesCallback() {
@Override
public void onRecipesLoaded(List<Recipe> recipes) {
refreshCache(recipes);
callback.onRecipesLoaded(new ArrayList<>(mCachedRecipes.values()));
}
@Override
public void onDataNotAvailable(int errorCode, String errorMessage) {
getRecipesFromRemoteDataSource(callback);
}
});
}
return false;
}
@Override
public void saveRecipe(@NonNull Recipe recipe) {
checkNotNull(recipe);
mRecipesRemoteDataSource.saveRecipe(recipe);
mRecipesLocalDataSource.saveRecipe(recipe);
// Do in memory cache update to keep the app UI up to date
if (mCachedRecipes == null) {
mCachedRecipes = new LinkedHashMap<>();
}
mCachedRecipes.put(recipe.getId(), recipe);
}
/**
* Gets recipes from local data source (sqlite).
* <p>
* Note: {@link LoadRecipeCallback#onDataNotAvailable()} is fired if local data was cleared
*/
@Override
public void getRecipe(final int recipeId, @NonNull final LoadRecipeCallback callback) {
Recipe cachedRecipe = getRecipeWithId(recipeId);
// Respond immediately with cache if available
if (cachedRecipe != null) {
callback.onRecipeLoaded(cachedRecipe);
return;
}
// Load from persisted if needed.
// Is the recipe in the local data source? If not, the app data was cleared.
mRecipesLocalDataSource.getRecipe(recipeId, new LoadRecipeCallback() {
@Override
public void onRecipeLoaded(Recipe recipe) {
// Do in memory cache update to keep the app UI up to date
if (mCachedRecipes == null) {
mCachedRecipes = new LinkedHashMap<>();
}
mCachedRecipes.put(recipe.getId(), recipe);
callback.onRecipeLoaded(recipe);
}
@Override
public void onDataNotAvailable() {
// it's a invalid recipe or it was removed from cache.
callback.onDataNotAvailable();
}
});
}
@Override
public void refreshRecipes() {
mCacheIsDirty = true;
}
@Override
public void deleteAllRecipes() {
mRecipesRemoteDataSource.deleteAllRecipes();
mRecipesLocalDataSource.deleteAllRecipes();
if (mCachedRecipes == null) {
mCachedRecipes = new LinkedHashMap<>();
}
mCachedRecipes.clear();
}
private void getRecipesFromRemoteDataSource(@NonNull final LoadRecipesCallback callback) {
mRecipesRemoteDataSource.getRecipes(new LoadRecipesCallback() {
@Override
public void onRecipesLoaded(List<Recipe> recipes) {
refreshCache(recipes);
refreshLocalDataSource(recipes);
callback.onRecipesLoaded(new ArrayList<>(mCachedRecipes.values()));
}
@Override
public void onDataNotAvailable(int errorCode, String errorMessage) {
callback.onDataNotAvailable(errorCode, errorMessage);
}
});
}
private void refreshCache(List<Recipe> recipes) {
if (mCachedRecipes== null) {
mCachedRecipes = new LinkedHashMap<>();
}
mCachedRecipes.clear();
for (Recipe recipe: recipes) {
mCachedRecipes.put(recipe.getId(), recipe);
}
// clean cached items
mCachedSteps = null;
mCachedStepsByRecipe = null;
mCachedIngredientsByRecipe = null;
mCacheIsDirty = false;
}
private void refreshLocalDataSource(List<Recipe> recipes) {
mRecipesLocalDataSource.deleteAllRecipes();
for (Recipe recipe: recipes) {
mRecipesLocalDataSource.saveRecipe(recipe);
}
}
@Nullable
private Recipe getRecipeWithId(int id) {
if (mCachedRecipes == null || mCachedRecipes.isEmpty()) {
return null;
} else {
return mCachedRecipes.get(id);
}
}
/*
* RECIPE STEPS
*/
@Override
public void getSteps(final int recipeId, @NonNull final LoadStepsCallback callback) {
List<Step> cachedSteps = getStepsWithRecipeId(recipeId);
// Respond immediately with cache if available
if (cachedSteps != null) {
callback.onStepsLoaded(cachedSteps);
return;
}
// Load from persisted if needed.
// Is the steps in the local data source? If not, the app data was cleared.
mRecipesLocalDataSource.getSteps(recipeId, new LoadStepsCallback() {
@Override
public void onStepsLoaded(List<Step> steps) {
// Do in memory cache update to keep the app UI up to date
if (mCachedStepsByRecipe == null) {
mCachedStepsByRecipe = new LinkedHashMap<>();
}
mCachedStepsByRecipe.put(recipeId, steps);
callback.onStepsLoaded(steps);
}
@Override
public void onDataNotAvailable() {
// it's a invalid recipe or it was removed from cache.
callback.onDataNotAvailable();
}
});
}
@Override
public void getStep(final int recipeId, final int stepId, @NonNull final LoadStepCallback callback) {
Step cachedStep = getStepWithRecipeIdAndStepId(recipeId, stepId);
// Respond immediately with cache if available
if (cachedStep != null) {
callback.onStepLoaded(cachedStep);
return;
}
// Load from persisted if needed.
// Is the steps in the local data source? If not, the app data was cleared.
mRecipesLocalDataSource.getStep(recipeId, stepId, new LoadStepCallback() {
@Override
public void onStepLoaded(Step step) {
// Do in memory cache update to keep the app UI up to date
if (mCachedSteps == null) {
mCachedSteps = new LinkedHashMap<>();
}
Map<Integer, Step> recipeSteps = mCachedSteps.get(recipeId);
if(recipeSteps == null) {
recipeSteps = new LinkedHashMap<>();
mCachedSteps.put(recipeId, recipeSteps);
}
recipeSteps.put(stepId, step);
callback.onStepLoaded(step);
}
@Override
public void onDataNotAvailable() {
// it's a invalid recipe or it was removed from cache.
callback.onDataNotAvailable();
}
});
}
@Override
public void getIngredients(final int recipeId, @NonNull final LoadIngredientsCallback callback) {
List<Ingredient> cachedIngredients = getIngredientsWithRecipeId(recipeId);
// Respond immediately with cache if available
if (cachedIngredients != null) {
callback.onIngredientsLoaded(cachedIngredients);
return;
}
// Load from persisted if needed.
// Is the ingredients in the local data source? If not, the app data was cleared.
mRecipesLocalDataSource.getIngredients(recipeId, new LoadIngredientsCallback() {
@Override
public void onIngredientsLoaded(List<Ingredient> ingredients) {
// Do in memory cache update to keep the app UI up to date
if (mCachedIngredientsByRecipe == null) {
mCachedIngredientsByRecipe = new LinkedHashMap<>();
}
mCachedIngredientsByRecipe.put(recipeId, ingredients);
callback.onIngredientsLoaded(ingredients);
}
@Override
public void onDataNotAvailable() {
// it's a invalid recipe or it was removed from cache.
callback.onDataNotAvailable();
}
});
}
@Override
public List<Ingredient> getIngredients(int recipeId) {
List<Ingredient> cachedIngredients = getIngredientsWithRecipeId(recipeId);
// Respond immediately with cache if available
if (cachedIngredients != null) {
return cachedIngredients;
}
// Load from persisted if needed.
// Is the ingredients in the local data source? If not, the app data was cleared.
List<Ingredient> ingredients = mRecipesLocalDataSource.getIngredients(recipeId);
// Do in memory cache update to keep the app UI up to date
if (mCachedIngredientsByRecipe == null) {
mCachedIngredientsByRecipe = new LinkedHashMap<>();
}
mCachedIngredientsByRecipe.put(recipeId, ingredients);
return ingredients;
}
@Nullable
private List<Step> getStepsWithRecipeId(int recipeId) {
if (mCachedStepsByRecipe == null|| mCachedStepsByRecipe.isEmpty()) {
return null;
} else {
return mCachedStepsByRecipe.get(recipeId);
}
}
@Nullable
private Step getStepWithRecipeIdAndStepId(int recipeId, int stepId) {
if (mCachedSteps == null || mCachedSteps.isEmpty()) {
return null;
}
Map<Integer, Step> recipeSteps = mCachedSteps.get(recipeId);
if(recipeSteps == null || recipeSteps.isEmpty()) {
return null;
}
return recipeSteps.get(stepId);
}
@Nullable
private List<Ingredient> getIngredientsWithRecipeId(int recipeId) {
if (mCachedIngredientsByRecipe == null|| mCachedIngredientsByRecipe.isEmpty()) {
return null;
} else {
return mCachedIngredientsByRecipe.get(recipeId);
}
}
}
| [
"[email protected]"
] | |
9f278f78ade6982d4115aaa2a6f9fa06382fa2a0 | c6662cebbaae0515c9a1ead046d9e7080ad098a4 | /gmall-manage-service/src/main/java/com/liujianhui/gmall/manage/mapper/PmsBaseSaleAttrMapper.java | 8f58696c1c7ac3b2c761db85055453ff795025d7 | [] | no_license | liujianhui1204/gmall0105 | e529e8ee6b0819aba7d0198ac2d359421fc1097b | a91d2fabc766ca5a95a77a32f7ffe1d3a45feefd | refs/heads/master | 2022-10-07T21:55:24.200050 | 2020-01-02T05:36:27 | 2020-01-02T05:36:27 | 226,289,088 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | package com.liujianhui.gmall.manage.mapper;
import com.liujianhui.gmall.bean.PmsBaseSaleAttr;
import tk.mybatis.mapper.common.Mapper;
public interface PmsBaseSaleAttrMapper extends Mapper<PmsBaseSaleAttr> {
}
| [
"liujianhui1204"
] | liujianhui1204 |
77f7e832f24574232e62314348af9235db79049f | 1e618f5a7bb683a516578e626b8ac42e45b4c0d4 | /src/controller/view/game/GameController.java | 9c320f7aad1c34fbb854ea752f32a25f63a9fe83 | [] | no_license | Dorian77210/Zomby-Game | aee9fc8b600a1b71f391dca2b024db593f377732 | 49174decad36451b7ec737d0a9fda54e9d3bf5ac | refs/heads/master | 2020-04-19T10:49:02.989345 | 2019-02-19T19:11:05 | 2019-02-19T19:11:05 | 168,150,525 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,068 | java | package controller.view.game;
import controller.base.KeyController;
import model.game.Player;
import ui.view.game.GameView;
import enums.GameActions;
import engine.Engine;
import engine.control.Keyboard;
import java.awt.event.KeyEvent;
public class GameController extends KeyController {
private GameView gameView;
public GameController(GameView gameView) {
this.gameView = gameView;
this.gameView.addKeyListener(this);
}
@Override
public void keyPressed(KeyEvent event) {
int keyCode = event.getKeyCode();
String touch = KeyEvent.getKeyText(keyCode);
//retrieve GameActions
final Keyboard keyboard = Engine.instance().getKeyboard();
GameActions action = keyboard.touchToAction(touch);
if(action != null) {
Player player = Engine.instance().getPlayer();
player.entity().update(action);
}
}
@Override
public void keyTyped(KeyEvent event) {
}
@Override
public void keyReleased(KeyEvent event) {
}
} | [
"[email protected]"
] | |
5a15d8b5a50cb2c2cf45dc6b43748c0d059b9713 | df82d01f0c4b8199d490d39be4782be63bdbe98f | /NigiriW.java | ac7552ec36adf0d50b2360a7e7fdbc25adc2cfa1 | [] | no_license | haveswing/nigiri | 1083c59c3481c4794c188d76ccc0dd2196092932 | ac6f6ecdd2772127739429eb7b3ba4208ea2d4d8 | refs/heads/master | 2021-01-17T19:59:39.974826 | 2016-06-09T12:21:52 | 2016-06-09T12:21:52 | 60,771,612 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,864 | java | import java.util.Scanner;
import java.util.Random;
public class NigiriW {
static int blackTake;
static int whiteTake;
public static void main(String[] args) {
System.out.println("Nigiri - Cai xian - Tol kariki");
System.out.println();
System.out.println("First player to pick 1 or 2 black stones,");
int blackTake = (int)(Math.random() * 2 + 1);
System.out.println();
System.out.println("Black stones picked.");
System.out.println();
System.out.println("How many white stones want to pick?");
System.out.println("(min.1 - max. 20):");
Scanner whiteChoice = new Scanner(System.in);
whiteTake = whiteChoice.nextInt();
if (whiteTake >= 21) {
System.out.println("You must pick min.1/max.20 white stones.");
return;
}
else {
System.out.println("You have picked " + whiteTake + " white stones.");
}
if (blackTake == 1) {
System.out.println();
System.out.println("Other player take " + blackTake + " black stone.");
}
else {
System.out.println();
System.out.println("Other player take " + blackTake + " black stones.");
}
if ((whiteTake % 2) == 0) {
if (blackTake == 1) {
System.out.println();
System.out.println("You win! :)");
System.out.println("You will play with black stones.");
}
else {
System.out.println();
System.out.println("You lose! :(");
System.out.println("You will play with white stones.");
}
}
else {
if (blackTake == 2) {
System.out.println();
System.out.println("You win! :)");
System.out.println("You will play with black stones.");
}
else {
System.out.println();
System.out.println("You lose! :(");
System.out.println("You will play with white stones.");
}
}
}
}
| [
"[email protected]"
] | |
3ab7be6bc2766461cce34c25546f8628f5aee21c | a87020f3cb01a85d3ca5dc4297bc1ad58f5c6df7 | /eims/src/cn/qtone/common/components/syspurview/core/user/dao/mysql/MySQLUserDAO.java | c30c40d67046e60e879892ac371bdd3868749f27 | [] | no_license | ericisme/eims | 9bd2d9a1d1c4ee883b7dff726c3ce291980e77f8 | 2235e992bee8802ce9034a672902820b81c96e8c | refs/heads/master | 2016-09-06T02:01:12.848370 | 2014-07-17T08:16:19 | 2014-07-17T08:16:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,990 | java | package cn.qtone.common.components.syspurview.core.user.dao.mysql;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.jdbc.core.PreparedStatementSetter;
import cn.qtone.common.components.syspurview.core.user.dao.BaseUserDAO;
import cn.qtone.common.components.syspurview.core.user.dao.IUserDAO;
import cn.qtone.common.components.syspurview.core.user.dao.UserMapper;
import cn.qtone.common.components.syspurview.core.user.domain.User;
import cn.qtone.common.components.syspurview.core.user.qvo.QvoUser;
import cn.qtone.common.mvc.dao.Page;
import cn.qtone.common.utils.base.StringUtil;
import cn.qtone.qtoneframework.web.servlet.ServletUtil;
/**
* 用户管理的mysql数据库实现DAO。
*
* @author 马必强
*
*/
public class MySQLUserDAO extends BaseUserDAO implements IUserDAO
{
public void query(Page page)
{
if (log.isInfoEnabled()) {
log.info("[mysql]查询用户列表,start=" + (page.getStartIndex() - 1)
+ ",pageSize=" + page.getPageSize());
}
String sql = "SELECT userId,a.groupId,groupName,loginName,loginPassword,realName,man, a.town_id,a.agency_id,a.school_id,a.grade_id,a.class_id,a.id_card,a.status,"
+ " mobile,email,birthday,addTime,lastLoginTime,lastLoginIP,isLock,loginTimes,a.USER_TYPE,c.DEPT_ID,c.DEPT_NAME "
+ " FROM sys_user a LEFT JOIN sys_group b ON a.groupId=b.groupId "
+ " LEFT JOIN t_dept c on a.DEPT_ID=c.DEPT_ID"
+ " WHERE isSuper=0 LIMIT ?,?";
if(log.isInfoEnabled()) log.info("用户查询:"+sql);
final Page p = page;
List result = this.getJdbcTemplate().query(sql, new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException
{
ps.setInt(1, p.getStartIndex() - 1);
ps.setInt(2, p.getPageSize());
}
}, new UserMapper());
page.setResult(result);
page.setTotals(this.queryCount());
}
public void query(Page page, String name)
{
if (log.isInfoEnabled()) {
log.info("[mysql]查询用户列表,start=" + (page.getStartIndex() - 1)
+ ",pageSize=" + page.getPageSize() + ",name=" + name);
}
String qName = StringUtil.toDBFilter(name);
String sql = "SELECT userId,a.groupId,groupName,loginName,loginPassword,realName,man, a.town_id,a.agency_id,a.school_id,a.grade_id,a.class_id,a.id_card,a.status,"
+ "mobile,email,birthday,addTime,lastLoginTime,lastLoginIP,isLock,loginTimes,a.USER_TYPE,c.DEPT_ID,c.DEPT_NAME "
+ "FROM sys_user a LEFT JOIN sys_group b ON a.groupId=b.groupId "
+ " LEFT JOIN t_dept c on a.DEPT_ID=c.DEPT_ID "
+ "WHERE isSuper=0 AND realName LIKE '%" + qName + "%' LIMIT ?,?";
if(log.isInfoEnabled()) log.info("用户查询:"+sql);
final Page p = page;
List result = this.getJdbcTemplate().query(sql, new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException
{
ps.setInt(1, p.getStartIndex() - 1);
ps.setInt(2, p.getPageSize());
}
}, new UserMapper());
page.setResult(result);
page.setTotals(this.queryCount(name));
}
public void query(Page page, int groupId)
{
if (log.isInfoEnabled()) {
log.info("[mysql]查询用户列表,start=" + (page.getStartIndex() - 1)
+ ",pageSize=" + page.getPageSize() + ",groupId=" + groupId);
}
String sql = "SELECT userId,a.groupId,groupName,loginName,loginPassword,realName,man, a.town_id,a.agency_id,a.school_id,a.grade_id,a.class_id,a.id_card,a.status,"
+ "mobile,email,birthday,addTime,lastLoginTime,lastLoginIP,isLock,loginTimes,a.USER_TYPE,c.DEPT_ID,c.DEPT_NAME,isManageAllTown "
+ "FROM sys_user a LEFT JOIN sys_group b ON a.groupId=b.groupId "
+ " LEFT JOIN t_dept c on a.DEPT_ID=c.DEPT_ID "
+ "WHERE isSuper=0 AND a.groupId=? LIMIT ?,?";
final Page p = page;
final int gId = groupId;
List result = this.getJdbcTemplate().query(sql, new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException
{
ps.setInt(1, gId);
ps.setInt(2, p.getStartIndex() - 1);
ps.setInt(3, p.getPageSize());
}
}, new UserMapper());
page.setResult(result);
page.setTotals(this.queryCount(gId));
}
public void query(Page page, String name, int groupId)
{
if (log.isInfoEnabled()) {
log.info("[mysql]查询用户列表,start=" + (page.getStartIndex() - 1)
+ ",pageSize=" + page.getPageSize() + ",groupId=" + groupId
+ ",name=" + name);
}
String qName = StringUtil.toDBFilter(name);
String sql = "SELECT userId,a.groupId,groupName,loginName,loginPassword,realName,man,a.town_id,a.agency_id,a.school_id,a.grade_id,a.class_id,a.id_card,a.status,"
+ "mobile,email,birthday,addTime,lastLoginTime,lastLoginIP,isLock,loginTimes,a.USER_TYPE,c.DEPT_ID,c.DEPT_NAME,isManageAllTown "
+ "FROM sys_user a LEFT JOIN sys_group b ON a.groupId=b.groupId "
+ " LEFT JOIN t_dept c on a.DEPT_ID=c.DEPT_ID "
+ "WHERE isSuper=0 AND a.groupId=? AND realName LIKE '%" + qName + "%' LIMIT ?,?";
final Page p = page;
final int gId = groupId;
List result = this.getJdbcTemplate().query(sql, new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException
{
ps.setInt(1, gId);
ps.setInt(2, p.getStartIndex() - 1);
ps.setInt(3, p.getPageSize());
}
}, new UserMapper());
page.setResult(result);
page.setTotals(this.queryCount(name, groupId));
}
public void addUser(User user)
{
try {
if (log.isInfoEnabled()) {
log.info("[mysql]添加用户信息:" + StringUtil.reflectObj(user));
}
String sql = "INSERT INTO sys_user(loginName,loginPassword,realName,"
+ "mobile,email,addTime,isSuper,groupId,USER_TYPE,DEPT_ID,plainCode,town_id,agency_id,school_id,grade_id,class_id,id_card,status) "
+ " VALUES(?,?,?,?,?,now(),0,?,?,?,?,?,?,?,?,?,?,?)";
final User u = user;
this.getJdbcTemplate().update(sql, new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException
{
ps.setString(1, u.getLoginName());
ps.setString(2, u.getLoginPassword());
ps.setString(3, u.getRealName());
ps.setString(4, u.getMobile());
ps.setString(5, u.getEmail());
ps.setInt(6, u.getGroupId());
ps.setString(7,u.getUserType());
ps.setInt(8,u.getParentId());
ps.setString(9, u.getPlainCode());
ps.setInt(10, u.getTown_id());
ps.setInt(11, u.getAgency_id());
ps.setInt(12, u.getSchool_id());
ps.setInt(13, u.getGrade_id());
ps.setInt(14, u.getClass_id());
ps.setString(15, u.getId_card());
ps.setInt(16, u.getStatus());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
public User getUser(int userId)
{
if (log.isInfoEnabled()) log.info("获取用户[" + userId + "的详细信息!");
String sql = "SELECT userId,a.groupId,groupName,loginName,loginPassword,realName, a.town_id,a.agency_id,a.school_id,a.grade_id,a.class_id,a.id_card,a.status,"
+ " mobile,email,addTime,lastLoginTime,lastLoginIP,isLock,loginTimes,a.USER_TYPE,c.DEPT_ID,c.DEPT_NAME "
+ " FROM sys_user a LEFT JOIN sys_group b ON a.groupId=b.groupId "
+ " LEFT JOIN t_dept c ON a.DEPT_ID=c.DEPT_ID"
+ " WHERE userId=" + userId;
System.out.println("------>"+sql);
return (User)this.getJdbcTemplate().queryForObject(sql, new UserMapper());
}
public void updateUser(User user)
{
if (log.isInfoEnabled()) {
log.info("[mysql]更新用户信息:" + StringUtil.reflectObj(user));
}
String sql = "UPDATE sys_user SET realName=?,mobile=?,email=?,"
+ "groupId=?,USER_TYPE=?,DEPT_ID=?,town_id=?,agency_id=?,school_id=?,grade_id=?,class_id=?,id_card=?,status=? WHERE userId=?";
final User u = user;
this.getJdbcTemplate().update(sql, new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException
{
ps.setString(1, u.getRealName());
ps.setString(2, u.getMobile());
ps.setString(3, u.getEmail());
ps.setInt(4, u.getGroupId());
ps.setString(5,u.getUserType());
ps.setInt(6, u.getParentId());
ps.setInt(7, u.getTown_id());
ps.setInt(8, u.getAgency_id());
ps.setInt(9, u.getSchool_id());
ps.setInt(10, u.getGrade_id());
ps.setInt(11, u.getClass_id());
ps.setString(12, u.getId_card());
ps.setInt(13, u.getStatus());
ps.setInt(14, u.getUserId());
}
});
}
public void query(Page page,QvoUser qvo)
{
StringBuffer sql = new StringBuffer();
sql.append("SELECT a.userId,a.groupId,a.loginTimes,groupName,loginName,loginPassword,realName, a.town_id,a.agency_id,a.school_id,a.grade_id,a.class_id,a.id_card,a.status,"
+ "mobile,email,addTime as addTime,"
+ "lastLoginTime as lastLoginTime,"
+ "lastLoginIP,isLock,a.user_type FROM sys_user a LEFT JOIN sys_group b "
+ " ON a.groupId=b.groupId ");
sql.append(" WHERE isSuper=0 ");
if(ServletUtil.notEqualF1(qvo.getQueryUserType())){
sql.append(" and a.user_type like '"+qvo.getQueryUserType()+"'");
}
if(ServletUtil.notEqualF1(qvo.getQryGroupId())){
sql.append(" AND a.groupId="+StringUtil.parseInt(qvo.getQryGroupId(), -1));
}
if(StringUtils.isNotBlank(qvo.getQryName())){
sql.append(" AND a.realName LIKE '%"+ qvo.getQryName() + "%'");
}
sql.append(" order by groupId,addTime ");
sql.append(" LIMIT "+(page.getStartIndex()==1?0:page.getStartIndex())+","+page.getPageSize());
final int gId = StringUtil.parseInt(qvo.getQryGroupId(), -1);
List result = this.getJdbcTemplate().query(sql.toString(), new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException
{
}
}, new UserMapper());
page.setResult(result);
page.setTotals(this.queryCount(qvo));
}
}
| [
"[email protected]"
] | |
3154fb2932c53f0dc708bea7870cd231509e7c76 | 537bc89541b087e9a16084e04e62fe5bbd44e2b1 | /lab/lab03/SimpleApp/app/src/main/java/lab03/kmitl/simpleapp/view/DotView.java | ffa50b7dc0a80b83255530d825bbfe6d7446425a | [] | no_license | tanapon395/course-android-kmitl | 79ccef2786a1f1870da056c13addf4953244c97a | e2ec6ee3a87c5897487d2b1ce0e9f2cf56468aa0 | refs/heads/master | 2021-07-24T20:59:39.112877 | 2017-11-06T01:51:29 | 2017-11-06T01:51:29 | 109,670,559 | 1 | 0 | null | 2017-11-06T08:56:34 | 2017-11-06T08:56:33 | null | UTF-8 | Java | false | false | 1,772 | java | package lab03.kmitl.simpleapp.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import lab03.kmitl.simpleapp.model.Dot;
import lab03.kmitl.simpleapp.model.Dots;
public class DotView extends View {
public interface OnDotViewPressListener {
void onPress(DotView dotView, int x, int y);
}
private Paint paint;
private Dots dots;
public DotView(Context context) {
super(context);
paint = new Paint();
}
public DotView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
paint = new Paint();
}
public DotView(Context context, AttributeSet attrs) {
super(context, attrs);
paint = new Paint();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if(dots != null) {
for (Dot dot: dots.getAll()) {
paint.setColor(dot.getColor());
canvas.drawCircle(dot.getCenterX(),
dot.getCenterY(),
dot.getRadius(), paint);
}
}
}
private OnDotViewPressListener listener;
public void setListener(OnDotViewPressListener listener) {
this.listener = listener;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
listener.onPress(this, (int)event.getX(), (int)event.getY());
}
return false;
}
public void setDots(Dots dots) {
this.dots = dots;
}
}
| [
"[email protected]"
] | |
38d6588df6bf4b09a69efbde4a3e600d619571fb | c9e0989b4f7f0561a2f70a27177ccef68ab58fd2 | /src/main/java/com/toseedata/wetripout/trip/VersionController.java | 3fb9f48c9bf1fd057c67aa3c76bfe5c7d94433cd | [] | no_license | 2cData/trip | 5df7d083eefc170e5df0677e6878daa535af12e6 | b7cf1a397bbbd0472b520300a5d2d1bf5c3f3fd4 | refs/heads/master | 2023-03-25T12:46:46.661817 | 2021-03-09T15:32:44 | 2021-03-09T15:32:44 | 345,153,383 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 384 | java | package com.toseedata.wetripout.trip;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/version")
public class VersionController {
@GetMapping()
public String getVersion() {
return "1.0";
}
}
| [
"[email protected]"
] | |
7b91b237fd360eff25dbc440690686dbcc8614ad | 1bd9490dc54d20763f5bfd7cbb06a84adbdc5b95 | /lab3/lab3/src/sample/ReadingFromFileBMPWithStandart.java | b25895aca6972a9cd14e42d8e9e4767fd9942812 | [] | no_license | dpalii/maokg | 682ae3117476f16a7054b74f6f7548ca43be2414 | a1a86bba84819613c74c35435438e56f924b6913 | refs/heads/main | 2023-04-16T16:14:18.900454 | 2021-05-04T12:27:04 | 2021-05-04T12:27:04 | 341,116,061 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,144 | java | package sample;
import javafx.animation.*;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.*;
import javafx.stage.Stage;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelReader;
import javafx.scene.paint.Color;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.util.Duration;
public class ReadingFromFileBMPWithStandart extends Application {
@Override
public void start(Stage primaryStage) {
Image image = new Image("file:C:\\Users\\dpali\\Documents\\маокг\\lab3\\picture.bmp");
PixelReader pixelReader = image.getPixelReader();
WritableImage wImage = new WritableImage((int)image.getWidth(), (int)image.getHeight());
PixelWriter pixelWriter = wImage.getPixelWriter();
for (int readY = 0; readY < image.getHeight(); readY++) {
for (int readX = 0; readX < image.getWidth(); readX++) {
Color color = pixelReader.getColor(readX, readY);
if (color.getBlue() != 1 && color.getGreen() != 1 && color.getRed() != 1) {
pixelWriter.setColor(readX,readY,color);
}
}
}
ImageView imageView = new ImageView();
imageView.setImage(wImage);
StackPane root = new StackPane();
root.getChildren().add(imageView);
// animation
final Duration SEC_2 = Duration.millis(2000);
final Duration SEC_3 = Duration.millis(3000);
Path path = new Path();
path.getElements().add(new MoveTo(20,20));
path.getElements().add(new LineTo(20,image.getHeight()));
path.getElements().add(new LineTo(image.getWidth(),image.getHeight()));
path.getElements().add(new LineTo(image.getWidth(),20));
path.getElements().add(new LineTo(20,20));
PathTransition pt = new PathTransition();
pt.setDuration(Duration.millis(4000));
pt.setPath(path);
pt.setNode(imageView);
pt.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
pt.setCycleCount(Timeline.INDEFINITE);
pt.setAutoReverse(true);
RotateTransition rt = new RotateTransition(SEC_3);
rt.setByAngle(180f);
rt.setCycleCount(Animation.INDEFINITE);
rt.setAutoReverse(true);
ScaleTransition st = new ScaleTransition(SEC_2);
st.setByX(-0.50f);
st.setByY(-0.5f);
st.setCycleCount(Animation.INDEFINITE);
st.setAutoReverse(true);
ParallelTransition animation = new ParallelTransition(imageView, pt, rt, st);
animation.play();
// animation end
Scene scene = new Scene(root, 2 * image.getWidth(), 2 * image.getHeight());
scene.setFill(Color.BLACK);
primaryStage.setTitle("lab3");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
} | [
"[email protected]"
] | |
6a10f3464f44e6dcf32e2db29c750693e5871a52 | 057f31acb1bbcc766d7f72720eedf5a9f3d94409 | /5136-Final/register.java | 674c1e76946c66a9a566ee934d07f715dd44d45e | [] | no_license | AustinYanghc/FIT5136 | 2332a13046ead860a566deb8fc88e0dd2aa6966c | 8bd0f481c1c5cc3afcbffda598149b1b728925fc | refs/heads/master | 2020-07-13T13:41:39.306128 | 2019-08-29T06:33:45 | 2019-08-29T06:33:45 | 205,095,266 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,591 | java | /**
*Text genereted by Simple GUI Extension for BlueJ
*/
import javax.swing.UIManager.LookAndFeelInfo;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import javax.swing.border.Border;
import javax.swing.*;
public class register extends JFrame {
private String userId;
private String type;
private JMenuBar menuBar;
private JButton button1;
private JButton button2;
private JCheckBox checkbox1;
private JCheckBox checkbox2;
private JLabel label1;
private JLabel label10;
private JLabel label2;
private JLabel label3;
private JLabel label4;
private JLabel label5;
private JLabel label6;
private JLabel label7;
private JLabel label8;
private JLabel label9;
private JLabel label11;
private JLabel label12;
private JPasswordField passwordfield1;
private JTextField textfield1;
private JTextField textfield2;
private JTextField textfield3;
private JTextField textfield4;
private JTextField textfield5;
private JTextField textfield6;
private JTextField textfield7;
private User user;
private SeekerController Seekercontroller;
private RecruiterController Recruitercontroller;
private VaildationController Vaildationcontroller;
//Constructor
public register(){
user = new User();
Seekercontroller = new SeekerController();
Recruitercontroller = new RecruiterController();
Vaildationcontroller = new VaildationController();
this.setTitle("GUI_project");
this.setSize(500,430);
//menu generate method
generateMenu();
this.setJMenuBar(menuBar);
//pane with null layout
JPanel contentPane = new JPanel(null);
contentPane.setPreferredSize(new Dimension(500,430));
contentPane.setBackground(new Color(255,255,255));
button1 = new JButton();
button1.setBounds(300,290,100,35);
button1.setBackground(new Color(255,255,255));
button1.setForeground(new Color(0,0,0));
button1.setEnabled(true);
button1.setFont(new Font("sansserif",0,12));
button1.setText("Register");
button1.setVisible(true);
button1.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent evt)
{
procceed1(evt);
}
});
button2 = new JButton();
button2.setBounds(300,355,100,35);
button2.setBackground(new Color(214,217,223));
button2.setForeground(new Color(0,0,0));
button2.setEnabled(true);
button2.setFont(new Font("sansserif",0,12));
button2.setText("Sign in");
button2.setVisible(true);
button2.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent evt)
{
procceed2(evt);
}
});
label1 = new JLabel();
label1.setBounds(200,5,119,36);
label1.setBackground(new Color(214,217,223));
label1.setForeground(new Color(0,0,0));
label1.setEnabled(true);
label1.setFont(new Font("SansSerif",0,23));
label1.setText("Register");
label1.setVisible(true);
label10 = new JLabel();
label10.setBounds(75,325,400,30);
label10.setBackground(new Color(214,217,223));
label10.setForeground(new Color(0,0,0));
label10.setEnabled(true);
label10.setFont(new Font("sansserif",0,12));
label10.setText("—————————————— or ——————————————");
label10.setVisible(true);
label2 = new JLabel();
label2.setBounds(35,60,90,35);
label2.setBackground(new Color(214,217,223));
label2.setForeground(new Color(0,0,0));
label2.setEnabled(true);
label2.setFont(new Font("sansserif",0,12));
label2.setText("UserName");
label2.setVisible(true);
label3 = new JLabel();
label3.setBounds(260,60,90,35);
label3.setBackground(new Color(214,217,223));
label3.setForeground(new Color(0,0,0));
label3.setEnabled(true);
label3.setFont(new Font("sansserif",0,12));
label3.setText("Name");
label3.setVisible(true);
label4 = new JLabel();
label4.setBounds(35,105,90,35);
label4.setBackground(new Color(214,217,223));
label4.setForeground(new Color(0,0,0));
label4.setEnabled(true);
label4.setFont(new Font("sansserif",0,12));
label4.setText("Email");
label4.setVisible(true);
label5 = new JLabel();
label5.setBounds(35,150,90,35);
label5.setBackground(new Color(214,217,223));
label5.setForeground(new Color(0,0,0));
label5.setEnabled(true);
label5.setFont(new Font("sansserif",0,12));
label5.setText("Password");
label5.setVisible(true);
label6 = new JLabel();
label6.setBounds(35,195,90,35);
label6.setBackground(new Color(214,217,223));
label6.setForeground(new Color(0,0,0));
label6.setEnabled(true);
label6.setFont(new Font("sansserif",0,12));
label6.setText("Address");
label6.setVisible(true);
label7 = new JLabel();
label7.setBounds(35,240,90,35);
label7.setBackground(new Color(214,217,223));
label7.setForeground(new Color(0,0,0));
label7.setEnabled(true);
label7.setFont(new Font("sansserif",0,12));
label7.setText("Dob");
label7.setVisible(true);
label12 = new JLabel();
label12.setBounds(35,290,90,35);
label12.setBackground(new Color(214,217,223));
label12.setForeground(new Color(0,0,0));
label12.setEnabled(true);
label12.setFont(new Font("sansserif",0,12));
label12.setText("Type");
label12.setVisible(true);
label8 = new JLabel();
label8.setBounds(230,240,90,35);
label8.setBackground(new Color(214,217,223));
label8.setForeground(new Color(0,0,0));
label8.setEnabled(true);
label8.setFont(new Font("sansserif",0,12));
label8.setText("MobileNumber");
label8.setVisible(true);
label9 = new JLabel();
label9.setBounds(80,355,182,32);
label9.setBackground(new Color(214,217,223));
label9.setForeground(new Color(0,0,0));
label9.setEnabled(true);
label9.setFont(new Font("sansserif",0,12));
label9.setText("* Already have an account ?");
label9.setVisible(true);
label11 = new JLabel();
label11.setBounds(80,400,382,32);
label11.setBackground(new Color(214,217,223));
label11.setForeground(new Color(0,0,0));
label11.setEnabled(true);
label11.setFont(new Font("sansserif",0,12));
label11.setText("");
label11.setVisible(true);
passwordfield1 = new JPasswordField();
passwordfield1.setBounds(100,150,350,30);
passwordfield1.setBackground(new Color(255,255,255));
passwordfield1.setForeground(new Color(255,255,255));
passwordfield1.setEnabled(true);
passwordfield1.setFont(new Font("sansserif",0,12));
passwordfield1.setVisible(true);
textfield1 = new JTextField();
textfield1.setBounds(100,60,130,30);
textfield1.setBackground(new Color(255,255,255));
textfield1.setForeground(new Color(0,0,0));
textfield1.setEnabled(true);
textfield1.setFont(new Font("sansserif",0,12));
textfield1.setText("");
textfield1.setVisible(true);
textfield2 = new JTextField();
textfield2.setBounds(320,60,130,30);
textfield2.setBackground(new Color(255,255,255));
textfield2.setForeground(new Color(0,0,0));
textfield2.setEnabled(true);
textfield2.setFont(new Font("sansserif",0,12));
textfield2.setText("");
textfield2.setVisible(true);
textfield3 = new JTextField();
textfield3.setBounds(100,105,350,30);
textfield3.setBackground(new Color(255,255,255));
textfield3.setForeground(new Color(0,0,0));
textfield3.setEnabled(true);
textfield3.setFont(new Font("sansserif",0,12));
textfield3.setText("");
textfield3.setVisible(true);
textfield4 = new JTextField();
textfield4.setBounds(100,195,350,30);
textfield4.setBackground(new Color(255,255,255));
textfield4.setForeground(new Color(0,0,0));
textfield4.setEnabled(true);
textfield4.setFont(new Font("sansserif",0,12));
textfield4.setText("");
textfield4.setVisible(true);
textfield5 = new JTextField();
textfield5.setBounds(100,240,110,30);
textfield5.setBackground(new Color(255,255,255));
textfield5.setForeground(new Color(0,0,0));
textfield5.setEnabled(true);
textfield5.setFont(new Font("sansserif",0,12));
textfield5.setText("");
textfield5.setVisible(true);
textfield6 = new JTextField();
textfield6.setBounds(330,240,120,30);
textfield6.setBackground(new Color(255,255,255));
textfield6.setForeground(new Color(0,0,0));
textfield6.setEnabled(true);
textfield6.setFont(new Font("sansserif",0,12));
textfield6.setText("");
textfield6.setVisible(true);
textfield7 = new JTextField();
textfield7.setBounds(100,290,130,30);
textfield7.setBackground(new Color(255,255,255));
textfield7.setForeground(new Color(0,0,0));
textfield7.setEnabled(true);
textfield7.setFont(new Font("sansserif",0,12));
textfield7.setText("");
textfield7.setVisible(true);
//adding components to contentPane panel
contentPane.add(button1);
contentPane.add(button2);
contentPane.add(label1);
contentPane.add(label10);
contentPane.add(label2);
contentPane.add(label3);
contentPane.add(label4);
contentPane.add(label5);
contentPane.add(label6);
contentPane.add(label7);
contentPane.add(label8);
contentPane.add(label9);
contentPane.add(label11);
contentPane.add(label12);
contentPane.add(passwordfield1);
contentPane.add(textfield1);
contentPane.add(textfield2);
contentPane.add(textfield3);
contentPane.add(textfield4);
contentPane.add(textfield5);
contentPane.add(textfield6);
contentPane.add(textfield7);
//adding panel to JFrame and seting of window position and close operation
this.add(contentPane);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.pack();
this.setVisible(true);
}
//method for generate menu
public void generateMenu(){
menuBar = new JMenuBar();
JMenu file = new JMenu("File");
JMenu tools = new JMenu("Tools");
JMenu help = new JMenu("Help");
JMenuItem open = new JMenuItem("Open ");
JMenuItem save = new JMenuItem("Save ");
JMenuItem exit = new JMenuItem("Exit ");
JMenuItem preferences = new JMenuItem("Preferences ");
JMenuItem about = new JMenuItem("About ");
file.add(open);
file.add(save);
file.addSeparator();
file.add(exit);
tools.add(preferences);
help.add(about);
menuBar.add(file);
menuBar.add(tools);
menuBar.add(help);
}
private void procceed1 (MouseEvent evt)
{
if (evt.getSource() == button1){
registerResult();
clearTextFields();
new mainPage(userId,type);
} /*else if (evt.getSource() == exitButton) {
System.exit(0);
} */
}
private void procceed2 (MouseEvent evt)
{
if (evt.getSource() == button2){
new login();
clearTextFields();
} /*else if (evt.getSource() == exitButton) {
System.exit(0);
} */
}
public String getUserId(){
String id = textfield1.getText();
return id ==null || id.isEmpty() ? "": id;
}
public String getUserName(){
String name = textfield2.getText();
return name ==null || name.isEmpty() ? "": name;
}
public String getUserType(){
String type = textfield7.getText();
return type ==null || type.isEmpty() ? "": type;
}
public String getUserEmail(){
String email = textfield3.getText();
return email ==null || email.isEmpty() ? "": email;
}
public String getUserPassword(){
String password = passwordfield1.getText();
return password ==null || password.isEmpty() ? "": password;
}
public String getUserAddress(){
String address = textfield4.getText();
return address ==null || address.isEmpty() ? "": address;
}
public String getUserDob(){
String dob = textfield5.getText();
return dob ==null || dob.isEmpty() ? "": dob;
}
public String getUserNumber(){
String number = textfield6.getText();
return number ==null || number.isEmpty() ? "": number;
}
public boolean registerResult(){
String userId = getUserId();
String password = getUserPassword();
String name = getUserName();
String email = getUserEmail();
String type = getUserType();
String address = getUserAddress();
String dob = getUserDob();
String number = getUserNumber();
boolean checkExist = Vaildationcontroller.checkExist(userId);
if(userId.equals("")|| password.equals("")||name.equals("")||email.equals("")||address.equals("")||dob.equals("")||number.equals("")){
label11.setText("These areas cannot be empty.");
return false;
} else if (!checkExist){
User user = new User(userId, name, password, email, type, address, dob, number);
this.userId = userId;
this.type = type;
Seekercontroller.createUser(user);
if (this.type.equalsIgnoreCase("seeker"))
Seekercontroller.createSeeker("default","default","default",userId);
else
Recruitercontroller.createCategory(userId,"default");
return true;
} else {
label11.setText("User is already exist");
return false;
}
}
public void clearTextFields(){
textfield1.setText("");
textfield2.setText("");
textfield3.setText("");
textfield4.setText("");
textfield5.setText("");
textfield6.setText("");
textfield7.setText("");
passwordfield1.setText("");
}
public static void main(String[] args){
System.setProperty("swing.defaultlaf", "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new register();
}
});
}
} | [
"[email protected]"
] | |
4a5f1c91ee6be2729e86f213f65af4812f3becf2 | b97cad7b2a03dd09547fd588755e32aacd963f72 | /src/test/java/org/mapdb/impl/EngineTest.java | 3cab12cbbd9dba0cceac4bdaf1272901808c6b31 | [
"CC-PDDC",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | niclash/MapDB | 2008f9a71e96b1083c0508bcf40db44a70c68ae2 | 4cc61e5f5c8c57cdb1272766874a549afabaa1a2 | refs/heads/master | 2020-04-05T18:33:54.879972 | 2014-09-01T08:26:52 | 2014-09-01T08:26:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,812 | java | package org.mapdb.impl;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.mapdb.Engine;
import org.mapdb.impl.binaryserializer.SerializerBase;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.mapdb.impl.binaryserializer.SerializerBase.BYTE_ARRAY_NOSIZE;
/**
* Tests contract of various implementations of Engine interface
*/
public abstract class EngineTest<ENGINE extends Engine>
{
protected abstract ENGINE openEngine();
void reopen()
{
if( !canReopen() )
{
return;
}
e.close();
e = openEngine();
}
boolean canReopen()
{
return true;
}
boolean canRollback()
{
return true;
}
ENGINE e;
@Before
public void init()
{
e = openEngine();
}
@Test
public void put_get()
{
Long l = 11231203099090L;
long recid = e.put( l, SerializerBase.LONG );
assertEquals( l, e.get( recid, SerializerBase.LONG ) );
}
@Test
public void put_reopen_get()
{
if( !canReopen() )
{
return;
}
Long l = 11231203099090L;
long recid = e.put( l, SerializerBase.LONG );
e.commit();
reopen();
assertEquals( l, e.get( recid, SerializerBase.LONG ) );
}
@Test
public void put_get_large()
{
byte[] b = new byte[ (int) 1e6 ];
new Random().nextBytes( b );
long recid = e.put( b, SerializerBase.BYTE_ARRAY_NOSIZE );
assertArrayEquals( b, e.get( recid, SerializerBase.BYTE_ARRAY_NOSIZE ) );
}
@Test
public void put_reopen_get_large()
{
if( !canReopen() )
{
return;
}
byte[] b = new byte[ (int) 1e6 ];
new Random().nextBytes( b );
long recid = e.put( b, SerializerBase.BYTE_ARRAY_NOSIZE );
e.commit();
reopen();
assertArrayEquals( b, e.get( recid, SerializerBase.BYTE_ARRAY_NOSIZE ) );
}
@Test
public void first_recid()
{
assertEquals( Store.LAST_RESERVED_RECID + 1, e.put( 1, SerializerBase.INTEGER ) );
}
@Test
public void compact0()
{
Long v1 = 129031920390121423L;
Long v2 = 909090901290129990L;
Long v3 = 998898989L;
long recid1 = e.put( v1, SerializerBase.LONG );
long recid2 = e.put( v2, SerializerBase.LONG );
e.commit();
e.compact();
assertEquals( v1, e.get( recid1, SerializerBase.LONG ) );
assertEquals( v2, e.get( recid2, SerializerBase.LONG ) );
long recid3 = e.put( v3, SerializerBase.LONG );
assertEquals( v1, e.get( recid1, SerializerBase.LONG ) );
assertEquals( v2, e.get( recid2, SerializerBase.LONG ) );
assertEquals( v3, e.get( recid3, SerializerBase.LONG ) );
e.commit();
assertEquals( v1, e.get( recid1, SerializerBase.LONG ) );
assertEquals( v2, e.get( recid2, SerializerBase.LONG ) );
assertEquals( v3, e.get( recid3, SerializerBase.LONG ) );
}
@Test
public void compact()
{
Map<Long, Long> recids = new HashMap<Long, Long>();
for( Long l = 0L; l < 1000; l++ )
{
recids.put( l,
e.put( l, SerializerBase.LONG ) );
}
e.commit();
e.compact();
for( Map.Entry<Long, Long> m : recids.entrySet() )
{
Long recid = m.getValue();
Long value = m.getKey();
assertEquals( value, e.get( recid, SerializerBase.LONG ) );
}
}
@Test
public void compact2()
{
Map<Long, Long> recids = new HashMap<Long, Long>();
for( Long l = 0L; l < 1000; l++ )
{
recids.put( l,
e.put( l, SerializerBase.LONG ) );
}
e.commit();
e.compact();
for( Long l = 1000L; l < 2000; l++ )
{
recids.put( l, e.put( l, SerializerBase.LONG ) );
}
for( Map.Entry<Long, Long> m : recids.entrySet() )
{
Long recid = m.getValue();
Long value = m.getKey();
assertEquals( value, e.get( recid, SerializerBase.LONG ) );
}
}
@Test
public void compact_large_record()
{
byte[] b = new byte[ 100000 ];
long recid = e.put( b, SerializerBase.BYTE_ARRAY_NOSIZE );
e.commit();
e.compact();
assertArrayEquals( b, e.get( recid, SerializerBase.BYTE_ARRAY_NOSIZE ) );
}
@Test
public void testSetGet()
{
long recid = e.put( (long) 10000, SerializerBase.LONG );
Long s2 = e.get( recid, SerializerBase.LONG );
assertEquals( s2, Long.valueOf( 10000 ) );
}
@Test
public void large_record()
{
byte[] b = new byte[ 100000 ];
Arrays.fill( b, (byte) 111 );
long recid = e.put( b, BYTE_ARRAY_NOSIZE );
byte[] b2 = e.get( recid, BYTE_ARRAY_NOSIZE );
assertArrayEquals( b, b2 );
}
@Test
public void large_record_update()
{
byte[] b = new byte[ 100000 ];
Arrays.fill( b, (byte) 111 );
long recid = e.put( b, BYTE_ARRAY_NOSIZE );
Arrays.fill( b, (byte) 222 );
e.update( recid, b, BYTE_ARRAY_NOSIZE );
byte[] b2 = e.get( recid, BYTE_ARRAY_NOSIZE );
assertArrayEquals( b, b2 );
e.commit();
reopen();
b2 = e.get( recid, BYTE_ARRAY_NOSIZE );
assertArrayEquals( b, b2 );
}
@Test
public void large_record_delete()
{
byte[] b = new byte[ 100000 ];
Arrays.fill( b, (byte) 111 );
long recid = e.put( b, BYTE_ARRAY_NOSIZE );
e.delete( recid, BYTE_ARRAY_NOSIZE );
}
@Test
public void large_record_larger()
{
byte[] b = new byte[ 10000000 ];
Arrays.fill( b, (byte) 111 );
long recid = e.put( b, BYTE_ARRAY_NOSIZE );
byte[] b2 = e.get( recid, BYTE_ARRAY_NOSIZE );
assertArrayEquals( b, b2 );
e.commit();
reopen();
b2 = e.get( recid, BYTE_ARRAY_NOSIZE );
assertArrayEquals( b, b2 );
}
@Test
public void test_store_reopen()
{
long recid = e.put( "aaa", SerializerBase.STRING_NOSIZE );
e.commit();
reopen();
String aaa = e.get( recid, SerializerBase.STRING_NOSIZE );
assertEquals( "aaa", aaa );
}
@Test
public void test_store_reopen_nocommit()
{
long recid = e.put( "aaa", SerializerBase.STRING_NOSIZE );
e.commit();
e.update( recid, "bbb", SerializerBase.STRING_NOSIZE );
reopen();
String expected = canRollback() && canReopen() ? "aaa" : "bbb";
assertEquals( expected, e.get( recid, SerializerBase.STRING_NOSIZE ) );
}
@Test
public void rollback()
{
long recid = e.put( "aaa", SerializerBase.STRING_NOSIZE );
e.commit();
e.update( recid, "bbb", SerializerBase.STRING_NOSIZE );
if( !canRollback() )
{
return;
}
e.rollback();
assertEquals( "aaa", e.get( recid, SerializerBase.STRING_NOSIZE ) );
}
@Test
public void rollback_reopen()
{
long recid = e.put( "aaa", SerializerBase.STRING_NOSIZE );
e.commit();
e.update( recid, "bbb", SerializerBase.STRING_NOSIZE );
if( !canRollback() )
{
return;
}
e.rollback();
assertEquals( "aaa", e.get( recid, SerializerBase.STRING_NOSIZE ) );
reopen();
assertEquals( "aaa", e.get( recid, SerializerBase.STRING_NOSIZE ) );
}
}
| [
"[email protected]"
] | |
cd48b9ee21937c45b23cefb66f03a569bf4795e9 | 8209acad9c074acc508b686cda6540a85acefdc6 | /jobby/src/main/java/entities/Candidature.java | 8092e9033461ed1a06b7339bc7d432917acc9113 | [
"MIT"
] | permissive | AmineDjeghri/Jobby | edc54d2a5d311c30e33af1ca87ca592967428cba | 7332b256059ab76628b3b4f58f2bb04a18aed642 | refs/heads/master | 2021-06-08T09:56:53.682704 | 2020-05-10T14:32:13 | 2020-05-10T14:32:13 | 136,337,650 | 8 | 0 | MIT | 2021-04-26T17:34:55 | 2018-06-06T14:07:05 | Java | UTF-8 | Java | false | false | 2,853 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package entities;
import enumerations.TypeReponseEnum;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
/**
*
* @author AmineD
*/
@Entity(name = "candidature")
@NamedQueries({
@NamedQuery(name = "Candidature.findByCvId", query = "SELECT c FROM candidature c WHERE c.id.cvId = :cvId")
, @NamedQuery(name = "Candidature.findByOffreId", query = "SELECT c FROM candidature c WHERE c.id.offreId = :offreId")
, @NamedQuery(name = "Candidature.countByOffreId", query = "SELECT COUNT(c) FROM candidature c WHERE c.id.offreId = :offreId")})
public class Candidature implements Serializable{
private static final long serialVersionUID = 1L;
@EmbeddedId
private CandidaturePK id;
@ManyToOne
@JoinColumn(name = "cv_id",insertable = false ,updatable = false)
private Cv cv;
@ManyToOne
@JoinColumn(name = "offre_id",insertable = false ,updatable = false)
private Offre offre;
@Column(name = "dateCandidature")
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date dateCandidature;
@Enumerated(EnumType.STRING)
private TypeReponseEnum typeReponse;
private boolean reponse;
public Candidature() {
typeReponse=TypeReponseEnum.waiting;
}
public CandidaturePK getId() {
return id;
}
public void setId(CandidaturePK id) {
this.id = id;
}
public Cv getCv() {
return cv;
}
public void setCv(Cv cv) {
this.cv = cv;
}
public Offre getOffre() {
return offre;
}
public void setOffre(Offre offre) {
this.offre = offre;
}
public Date getDateCandidature() {
return dateCandidature;
}
public void setDateCandidature(Date dateCandidature) {
this.dateCandidature = dateCandidature;
}
public boolean isReponse() {
return reponse;
}
public void setReponse(boolean reponse) {
this.reponse = reponse;
}
public TypeReponseEnum getTypeReponse() {
return typeReponse;
}
public void setTypeReponse(TypeReponseEnum typeReponse) {
this.typeReponse = typeReponse;
}
@Override
public String toString() {
return "Candidature{" + "id=" + id + '}';
}
}
| [
"[email protected]"
] | |
288961ca81d7141704243ffe883fd7f964d3f3ed | 71eab2a34418e97ba6b75c6eaab96bcc3ca268c4 | /Agenda/src/Util.java | d2bdd2a64dda5cc1e2beba13a1f337add1a1eabd | [] | no_license | MaryRuizMendoza/ActividadesJavaAcademy | a288a6010ad43304d92d893aec8e650603ad764e | cca19803a11932a99aecd43c4d89fff559043019 | refs/heads/master | 2020-09-21T18:53:14.876795 | 2019-12-04T05:57:37 | 2019-12-04T05:57:37 | 224,890,618 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 292 | java | import java.util.UUID;
public class Util {
public String generateID() {
String uuid = UUID.randomUUID().toString();
return uuid;
}
public static void main(String[] args) {
Util util = new Util();
for(int i = 0; i> 4; i++) {
System.out.println(util.generateID());
}
}
}
| [
"[email protected]"
] | |
905d78599aa42667dd19ea6e7ac7e4a0fbbd07e0 | 0b7283fe1beacfabfedd68d79debce0167f71eae | /src/br/iucas/poquer/testes/TesteVerificadorDePar.java | 7f3e2fe0976273afe69e4589a478083c144ebb13 | [] | no_license | lucasPereira/poquer | d91409587f040818fcc734f37cdf798a126b9def | a14bdcf1712fb715a13edcbb68dbe548d8d0604e | refs/heads/master | 2021-01-20T17:06:16.558531 | 2017-05-11T20:57:21 | 2017-05-12T02:19:32 | 90,863,812 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,124 | java | package br.iucas.poquer.testes;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import br.iucas.poquer.Carta;
import br.iucas.poquer.VerificacaoDeJogo;
import br.iucas.poquer.VerificadorDeJogo;
import br.iucas.poquer.VerificadorDePar;
import br.iucas.poquer.figuracao.FiguracaoCarta;
public class TesteVerificadorDePar {
private VerificadorDeJogo verificadorDePar;
private Carta asEspadas;
private Carta asCopas;
private Carta asPaus;
private Carta reiEspadas;
private Carta reiCopas;
private Carta dezPaus;
private Carta oitoPaus;
private Carta seisPaus;
private Carta doisEspadas;
private Carta doisCopas;
@Before
public void configurar() throws Exception {
FiguracaoCarta figuracaoCarta = new FiguracaoCarta();
asEspadas = figuracaoCarta.asEspadas();
asCopas = figuracaoCarta.asCopas();
asPaus = figuracaoCarta.asPaus();
reiEspadas = figuracaoCarta.reiEspadas();
reiCopas = figuracaoCarta.reiCopas();
dezPaus = figuracaoCarta.dezPaus();
oitoPaus = figuracaoCarta.oitoPaus();
seisPaus = figuracaoCarta.seisPaus();
doisEspadas = figuracaoCarta.doisEspadas();
doisCopas = figuracaoCarta.doisCopas();
verificadorDePar = new VerificadorDePar();
}
@Test
public void duasCartasDeMesmoValor() throws Exception {
List<Carta> cartas = Arrays.asList(asEspadas, asCopas);
VerificacaoDeJogo verificacao = verificadorDePar.verificar(cartas);
List<Carta> jogo = Arrays.asList(asEspadas, asCopas);
assertTrue(verificacao.valido());
assertEquals(jogo, verificacao.obterJogo());
}
@Test
public void duasCartasComValoresDiferentes() throws Exception {
List<Carta> cartas = Arrays.asList(asEspadas, reiEspadas);
VerificacaoDeJogo verificacao = verificadorDePar.verificar(cartas);
List<Carta> jogo = Arrays.asList();
assertFalse(verificacao.valido());
assertEquals(jogo, verificacao.obterJogo());
}
@Test
public void doisPares() throws Exception {
List<Carta> cartas = Arrays.asList(reiEspadas, reiCopas, asEspadas, asCopas);
VerificacaoDeJogo verificacao = verificadorDePar.verificar(cartas);
List<Carta> jogo = Arrays.asList(asEspadas, asCopas, reiEspadas, reiCopas);
assertTrue(verificacao.valido());
assertEquals(jogo, verificacao.obterJogo());
}
@Test
public void parComTresCartasNaoOrdenadas() throws Exception {
List<Carta> cartas = Arrays.asList(dezPaus, reiEspadas, oitoPaus, reiCopas, asPaus);
VerificacaoDeJogo verificacao = verificadorDePar.verificar(cartas);
List<Carta> jogo = Arrays.asList(reiEspadas, reiCopas, asPaus, dezPaus, oitoPaus);
assertTrue(verificacao.valido());
assertEquals(jogo, verificacao.obterJogo());
}
@Test
public void seteCartasParAltoParBaixo() throws Exception {
List<Carta> cartas = Arrays.asList(oitoPaus, asEspadas, doisEspadas, seisPaus, asCopas, doisCopas, dezPaus);
VerificacaoDeJogo verificacao = verificadorDePar.verificar(cartas);
List<Carta> jogo = Arrays.asList(asEspadas, asCopas, dezPaus, oitoPaus, seisPaus);
assertTrue(verificacao.valido());
assertEquals(jogo, verificacao.obterJogo());
}
}
| [
"[email protected]"
] | |
8659d7235984a44a91ebaa0bbec6fb685af1892d | 405021dfb19ce5460421ee86fcbd133ea0b38245 | /src/main/java/com/javalec/project_zagoga/mapper/AuthMapper.java | ee45e22c16dd2c3d365008722107ab9ed38c2762 | [] | no_license | TeamProjectsCode/zagoga | c85b2f27db71676994d5f24fe593bc2651524444 | e114db98d885a883887fa4655c83877b419fdace | refs/heads/main | 2023-06-13T09:15:20.736495 | 2021-07-12T12:36:42 | 2021-07-12T12:36:42 | 377,034,019 | 0 | 1 | null | 2021-06-16T10:56:45 | 2021-06-15T04:21:37 | Java | UTF-8 | Java | false | false | 798 | java | package com.javalec.project_zagoga.mapper;
import com.javalec.project_zagoga.dto.Users;
import com.javalec.project_zagoga.security.AuthValue;
import com.javalec.project_zagoga.mapper.sql.SecuritySQL;
import com.javalec.project_zagoga.vo.AuthInfo;
import org.apache.ibatis.annotations.*;
@Mapper
public interface AuthMapper {
@SelectProvider(value = SecuritySQL.class, method = "loadUserByName")
AuthValue loadUserByName(@Param("username") String username);
@Options(useGeneratedKeys = true, keyProperty = "authValue.sc_no")
@InsertProvider(value = SecuritySQL.class, method = "insertAuthValue")
void insertAuthValue(@Param("authValue") AuthValue authValue);
@UpdateProvider(value = SecuritySQL.class, method = "updatePW")
void updatePW(int sc_no, String encPwd);
}
| [
"[email protected]"
] | |
44116ce0f98cc7b96f4a6581075bd07d0acfed05 | c530bebad14c5191d98470c144b647e5157adf1a | /max_sub_sum_array.java | 75aaa5c719fecd8f9779e5b82fe04f63368a61f2 | [] | no_license | ertugrulkucukali/AlgoritmaAnaliziDersi2017 | 827d7936cd34a1c453ab4ca30768d0001406b273 | 006ada05cba9cd604aaf00c5ed66a9118290e152 | refs/heads/master | 2020-04-06T04:06:05.648894 | 2017-06-11T16:09:35 | 2017-06-11T16:09:35 | 83,033,280 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,266 | java | package javaapplication3;
public class JavaApplication3 {
public static int maxSubArray(int[] A){
int newsum=A[0];
int max=A[0];
for(int i=1;i<A.length;i++){
newsum=Math.max(newsum+A[i],A[i]);
max= Math.max(max, newsum);
}
return max;
}
public static void main(String[] args) {
int L[]={4,-3,2, 1 ,6,-1,-2,4};
int sinir=(L.length)/2;
int L1[]=new int[sinir];
int L2[]=new int[sinir];
int toplam1=0;
int toplam2=0;
for(int i=0;i<sinir;i++){
L1[i]=L[sinir-i-1];
}
for(int i=0;i<sinir;i++){
L2[i]=L[sinir+i];
}
for(int i=0;i<L1.length;i++){
System.out.println("L1 dizisi= "+L1[i]);
}
for(int i=0;i<L2.length;i++){
System.out.println("L2 dizisi= "+L2[i]);
}
System.out.println("L1 toplam= "+maxSubArray(L1));
System.out.println("L2 toplam= "+maxSubArray(L2));
int toplam=maxSubArray(L1)+maxSubArray(L2);
System.out.println("\nToplam = " + toplam );
}
}
| [
"[email protected]"
] | |
a6480bd9386e5b71b1f0f6a1c8508a4b7341078b | 658e0511fb4407daf3357a69b535024144221740 | /src/com/apiomat/nativemodule/gitdemomodule/GitDemoModule.java | 701bfe43db0d3037a4479630837d98ffba2d4ac2 | [] | no_license | apinaut/gitdemo | 58e0a1ba24fbf7fbe33a9bf10e9183f5d1782b9a | 2573433411b6a619b3591a818c036c0632deb55d | refs/heads/master | 2020-05-22T00:03:14.139700 | 2016-10-12T13:24:33 | 2016-10-12T13:24:33 | 62,138,012 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,726 | java | /*
* Copyright (c) 2011 - 2016, Apinauten GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.apiomat.nativemodule.gitdemomodule;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
import com.apiomat.nativemodule.IApplicationConfigProxy;
import com.apiomat.nativemodule.IModule;
import com.apiomat.nativemodule.Module;
import com.apiomat.nativemodule.IStaticMethods;
import com.apiomat.nativemodule.AbstractRestResource;
/**
* Generated class for starting and stopping your module.
*
* Please be aware that all overridden methods in this class are called internally with
* A NEW INSTANCE OF THIS CLASS every time. That is, you cannot use instance variables
* in these overriden methods, because they are initialized again before each call.
*
*/
@Module( description="",
usedModules={}, securityPermissions = {} )
public class GitDemoModule implements IModule
{
static IApplicationConfigProxy APP_CONFIG_PROXY;
static IStaticMethods AOM;
// sample for a module configuration
// @NativeModuleConfig(
// datatype = Type.TEXT,
// example = "localhost",
// title = "Server Hostname",
// info = "Hostname of the server",
// defaultValue = "localhost",
// order = 1 )
// public static String HOSTNAME = "GitDemoModule_hostname";
/**
* This method gets called once in the cluster when the module is uploaded.
*/
@Override
public void onDeploy( )
{
//TODO will be called on SDK upload or service start
}
/**
* This method gets called once in the cluster when the ApiOmat service is shutdown.
*/
@Override
public void onUndeploy( )
{
//TODO will be called when service shuts down (maintenance)
}
/**
* This method gets called when the configuration for an app changes for this module
*/
@Override
public void onConfigChanged( String appName, String configKey, String system )
{
// TODO Auto-generated method stub
}
/**
* This method may provide an implementation for your own REST interface
*/
@Override
public AbstractRestResource getSpecificRestResource( UriInfo uriInfo, HttpServletRequest servletRequest,
SecurityContext securityContext, Request wsRequest )
{
// TODO comment in to use a basic rest endpoint with a ping method
//return new RestClass( uriInfo, servletRequest, securityContext, wsRequest );
return null;
}
/**
* This method gets called every hour
*/
@Override
public void onCronHourly( final String appName, final String system )
{
// TODO Auto-generated method stub
}
/**
* This method gets called every day
*/
@Override
public void onCronDaily( final String appName, final String system )
{
// TODO Auto-generated method stub
}
/**
* This method gets called every week
*/
@Override
public void onCronWeekly( final String appName, final String system )
{
// TODO Auto-generated method stub
}
/**
* This method gets called every month
*/
@Override
public void onCronMonthly( final String appName, final String system )
{
// TODO Auto-generated method stub
}
}
| [
"[email protected]"
] | |
68bba3c9c867c1c5d9d602955846b14c2aa528f2 | d6716a65c8eed2e9e1ef295703c543920d5e9b1f | /src/main/java/catalogApp/client/presenter/helper/EditorInitializeHelper.java | c11fe020bd25d70585ddfe700a06a975d9969b46 | [] | no_license | AligoruM/NetCrackerPROJECT | b42d17cdd50716bbea71158007cdb84312190391 | 2f2a05c5c845d57097ba5650204cd980dcabb465 | refs/heads/master | 2020-04-09T06:44:21.338573 | 2019-02-12T09:02:57 | 2019-02-12T09:02:57 | 160,125,142 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 949 | java | package catalogApp.client.presenter.helper;
import catalogApp.client.view.components.FileUploader;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import static catalogApp.shared.constants.FileServiceConstants.IMAGE_FIELD;
import static catalogApp.shared.constants.FileServiceConstants.IMAGE_SERVICE_PATH;
public class EditorInitializeHelper {
public static void initFileUploader(Button uploadButton, FileUploader fileUploader){
fileUploader.setAction(GWT.getModuleBaseURL() + IMAGE_SERVICE_PATH);
fileUploader.setFileFieldName(IMAGE_FIELD);
uploadButton.addClickHandler(event -> {
String filename = fileUploader.getFileUpload().getFilename();
if (filename.isEmpty()) {
Window.alert("No File Specified!");
} else {
fileUploader.submit();
}
});
}
}
| [
"[email protected]"
] | |
7911acb9ba3b8e2d3116a3c2c61b4055e127ff46 | 7c958ac63e6c57a90d340ab63bc1972bcd28dc54 | /core/src/main/java/com/github/messenger/exceptions/ExpiredToken.java | cc668b85eee386027c7fb650ec4b76aa047a1a81 | [] | no_license | Danyyl-Lebid/Messenger | a68d30df6f318382a75cb538a85dcdafd8bfda2b | d76818b1013087c0040df4c4714c5e51b3790412 | refs/heads/main | 2023-05-14T13:28:11.804897 | 2021-06-06T12:36:47 | 2021-06-06T12:36:47 | 368,442,423 | 0 | 0 | null | 2021-06-10T09:05:36 | 2021-05-18T07:39:47 | Java | UTF-8 | Java | false | false | 204 | java | package com.github.messenger.exceptions;
public class ExpiredToken extends RuntimeException {
public ExpiredToken() {
}
public ExpiredToken(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
f3428c43ef7eae5972c84791a07812fddebd35d9 | 6ef2f5a6c7255844a47d916613ce2463a0242e02 | /apple-logs-api-log4j/src/main/java/com/appleframework/logs/tomcat/Log4JAccessLogValve.java | f13ca6025890ba442d56e6934010951cca081d68 | [
"Apache-2.0"
] | permissive | will2love/apple-logs | c85a7c56a145d99b30e03efad4730716c3d88bc5 | 0802af9bcdee4163f7cfed12dd4de80719c8b6b4 | refs/heads/master | 2021-05-29T21:45:31.872609 | 2015-10-23T14:42:37 | 2015-10-23T14:42:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 597 | java | package com.appleframework.logs.tomcat;
import org.apache.catalina.valves.AccessLogValve;
import org.apache.log4j.Logger;
/**
* @author hill.hu
*/
public class Log4JAccessLogValve extends AccessLogValve {
private final Logger logger = Logger.getLogger(this.getClass());
protected static final String info1 ="com.appleframework.logs.tomcat.Log4JAccessLogValve";
@Override
public void log(String message) {
logger.info(message);
}
@Override
public String getInfo()
{
return info1;
}
@Override
protected void open()
{
}
}
| [
"[email protected]"
] | |
548a7ee2fc677b85b530e8037e682490c2179f67 | c01d10b29b6c3156d5146a468366743a1f395a42 | /src/main/java/lesson3/primitives/R_Exceptions.java | f58f240f2091633c9ed2add015485848cd860531 | [] | no_license | VladimirCW/group6Lesson3 | bb194e9a362abd0348e867778b9ca63d0fa34983 | e6ac6c972f102af859eb93da360b257cbef4ea1d | refs/heads/master | 2023-01-20T02:54:42.304205 | 2020-11-24T20:00:17 | 2020-11-24T20:00:17 | 303,781,152 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,351 | java | package main.java.lesson3.primitives;
public class R_Exceptions {
public static void main(String[] args) {
first();
}
public static void loopMethod() {
int arr[] = {1,2,3,4};
for (int i = 0; i < arr.length; i++) {
if(arr[i]%2 ==0) {
//do smt
}
//do smt
/*try{
if(arr[i]%2 ==0) {
throw new Error("sdfasdasd");
}
} catch (Exception e) {
}*/
}
}
public static void first() {
System.out.println("FIRST");
try {
second();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("---------------");
}
public static void second() throws Exception {
System.out.println("SECOND");
third();
System.out.println("AFTER THIRD");
}
public static void third() throws Exception{
System.out.println("THIRD");
/*try{
System.out.println(10/0);
System.out.println("***************");
} catch (Exception e) {
System.out.println("Error detected");
} finally {
System.out.println("FINALLY BLOCK");
}*/
int arr[] = {1};
System.out.println(arr[15]);
}
}
| [
"[email protected]"
] | |
0f362aded5280beeff835a987eff46711916de33 | 35af03abb9ea0d7ac45280632b3ffab5a3949028 | /app/src/main/java/com/fskj/gaj/Util/PreferenceUtil.java | 9a047a52f2c3928a9a8da67a5eb15c2410be567a | [] | no_license | caixiaojie/Gaj | 437f0ab00067d460396501900f3a8cfc234e5753 | ca0ec2488fda788a5bf25a506d774f23de593667 | refs/heads/master | 2021-09-15T04:37:56.089063 | 2018-05-26T06:28:31 | 2018-05-26T06:28:31 | 103,710,436 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,114 | java | package com.fskj.gaj.Util;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
/**
* Description:SharedPreferences的管理类
*
*/
public class PreferenceUtil {
private static SharedPreferences mSharedPreferences = null;
private static Editor mEditor = null;
public static void init(Context context){
if (null == mSharedPreferences) {
mSharedPreferences = android.preference.PreferenceManager.getDefaultSharedPreferences(context) ;
}
}
public static void removeKey(String key){
mEditor = mSharedPreferences.edit();
mEditor.remove(key);
mEditor.commit();
}
public static void removeAll(){
mEditor = mSharedPreferences.edit();
mEditor.clear();
mEditor.commit();
}
public static void commitString(String key, String value){
mEditor = mSharedPreferences.edit();
mEditor.putString(key, value);
mEditor.commit();
}
public static String getString(String key, String faillValue){
return mSharedPreferences.getString(key, faillValue);
}
public static void commitInt(String key, int value){
mEditor = mSharedPreferences.edit();
mEditor.putInt(key, value);
mEditor.commit();
}
public static int getInt(String key, int failValue){
return mSharedPreferences.getInt(key, failValue);
}
public static void commitLong(String key, long value){
mEditor = mSharedPreferences.edit();
mEditor.putLong(key, value);
mEditor.commit();
}
public static long getLong(String key, long failValue) {
return mSharedPreferences.getLong(key, failValue);
}
public static void commitBoolean(String key, boolean value){
mEditor = mSharedPreferences.edit();
mEditor.putBoolean(key, value);
mEditor.commit();
}
public static Boolean getBoolean(String key, boolean failValue){
return mSharedPreferences.getBoolean(key, failValue);
}
}
| [
"[email protected]"
] | |
27b23362a639c3df61c1ffe85bfc4a01f47730c6 | 6729fc90bd07746a0e6188d77f030239852323ac | /Main.java | 36fa5b97e7385b37294dfb498e16cbc3e646c811 | [] | no_license | MartinAyvazyan/JavaFirstClasswork | 053c76e3c0508fff030bd0f1080ca09c8920edae | f595f3fef43a22b17739ea941fff22479756ab17 | refs/heads/master | 2020-03-21T09:59:05.229634 | 2018-06-23T19:42:18 | 2018-06-23T19:42:18 | 138,427,946 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 440 | java | import java.util.Arrays;
import java.util.Scanner;
class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int length = scanner.nextInt();
int[] arr = new int[length];
for(int i =0; i<arr.length; i++){
arr[i] = scanner.nextInt();
}
int a = arr[0];
for(int i = 0; i<arr.length-1; i++ ){
int c = (a-arr[i+1]);
int k = (c>>>31);
a = a-k*c;
}
System.out.println(a);
}
}
| [
"[email protected]"
] | |
79b89319eceb6c5624863338342d799324f26d1b | 5f7e173e7b5d446f9de79006d797b9f8eb1c0c35 | /src/main/java/com/aiapp/user/UserController.java | 65fd93ff0e0c75ff410041b35d6c74090c8a8f22 | [] | no_license | Demo96/MyAiApp | b541ff3c0ee46a8677b81e4839acc4136cc2096f | a4e3fc75ad8308bd69ddde3f9a6240d388079f24 | refs/heads/master | 2020-04-10T07:18:16.822539 | 2019-01-17T21:43:47 | 2019-01-17T21:43:47 | 160,877,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,346 | java | package com.aiapp.user;
import java.util.LinkedList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin
@RequestMapping("/users")
@RestController
public class UserController {
@Autowired
private UserService userService;
@PreAuthorize("hasRole('ADMIN')")
@GetMapping("")
public List<UserDTO> getAllUsers() {
return userService.getAllUsers();
}
@GetMapping("/{username}")
public UserDTO getUserByUsername(@PathVariable String username) {
return userService.getUserByUserName(username);
}
@PutMapping("/{username}")
public void updateUser(@RequestBody UserDTO userDTO, @PathVariable String username) {
userService.updateUser(userDTO);
}
}
| [
"[email protected]"
] | |
a2e7c11987c47588e799843b587ce9cf99cf9482 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /single-large-project/src/main/java/org/gradle/test/performancenull_70/Productionnull_6978.java | c89216aedd5fbca731cc522932a1cc45ac910e57 | [] | no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 585 | java | package org.gradle.test.performancenull_70;
public class Productionnull_6978 {
private final String property;
public Productionnull_6978(String param) {
this.property = param;
}
public String getProperty() {
return property;
}
private String prop0;
public String getProp0() {
return prop0;
}
public void setProp0(String value) {
prop0 = value;
}
private String prop1;
public String getProp1() {
return prop1;
}
public void setProp1(String value) {
prop1 = value;
}
}
| [
"[email protected]"
] | |
df422867dfc2c5cd33a0c5ea6136067cc2fc9a50 | cbfe18b3cde172aed732808eaaf3867f8eae049a | /src/MissionPeace/multiarray/SmallestRectangleBlackPixel.java | 6b7133c71324e9ba1207722700070b9956ca5afd | [] | no_license | RahulKRatan/adwantdsprep | a487823591b4958beb9ef6b3104967b79344e677 | 4a60f6080d4a3a8fba507d3fcc518700b8bbd391 | refs/heads/master | 2023-06-15T19:40:06.133073 | 2021-07-06T06:42:57 | 2021-07-06T06:42:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,390 | java | package MissionPeace.multiarray;
/**
* An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel.
* The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontally
* and vertically. Given the location (x, y) of one of the black pixels, return the area of the smallest
* (axis-aligned) rectangle that encloses all black pixels.
* https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels/
*/
public class SmallestRectangleBlackPixel {
public int minArea(char[][] image, int x, int y) {
int m = image.length;
int n = image[0].length;
int left = searchColumns(image, 0, y, 0, m - 1, true);
int right = searchColumns(image, y, n - 1, 0, m - 1, false);
int top = searchRows(image, 0, x, left, right, true);
int bottom = searchRows(image, x, m - 1, left, right, false);
return (right - left + 1)*(bottom - top + 1);
}
private int searchColumns(char[][] image, int i, int j, int top, int bottom, boolean opt) {
int result = 0;
while (i <= j) {
int k = top;
int mid = (i + j)/2;
while (k <= bottom && image[k][mid] == '0') {
k++;
}
if (k != bottom + 1) {
result = mid;
}
if ((k == bottom + 1) == opt) {
i = mid + 1;
} else {
j = mid - 1;
}
}
return result;
}
private int searchRows(char[][] image, int i, int j, int left, int right, boolean opt) {
int result = 0;
while (i <= j) {
int k = left;
int mid = (i + j)/2;
while (k <= right && image[mid][k] == '0') {
k++;
}
if (k != right + 1) {
result = mid;
}
if ((k == right + 1) == opt) {
i = mid + 1;
} else {
j = mid - 1;
}
}
return result;
}
public static void main(String args[]) {
char[][] image1 = {{'1'},{'1'}};
char[][] image = {{'0', '0', '1', '0'}, {'0', '1', '1', '0'}, {'0', '1', '0', '0'}};
SmallestRectangleBlackPixel sbp = new SmallestRectangleBlackPixel();
System.out.print(sbp.minArea(image, 0, 2));
}
}
| [
"[email protected]"
] | |
fafca4edc76da7629480864e17145c821fe8a843 | 5c9ce2face9ffa64da77510e422df8cfbe14c367 | /src/main/java/creational/factory_method/PadFactory.java | cbbe926ec835ddceed12a3d813c04fd2d4330ee2 | [] | no_license | whatjordan/design_pattern | 2ca24f5d52fe67d73937e3b9874e770b36bc53e7 | 15d2d1eea2303a8adbf139899290330f401f2033 | refs/heads/master | 2023-08-01T01:22:48.913144 | 2021-09-15T16:03:31 | 2021-09-15T16:03:31 | 386,965,422 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 170 | java | package creational.factory_method;
public class PadFactory extends ProductFactory {
@Override
public Product createProduct() {
return new Pad();
}
}
| [
"[email protected]"
] | |
0d7be6e71c6877eb20e8735a07f4b939e52921b5 | 22573b54ea5f639110295074cd203b0b7dba22c9 | /blogWebTest/src/com/blog/entity/UserRanking.java | a910432636219f7bad662fdf4735a8b3e63238ef | [] | no_license | starsky-web/blog | 49268daa7b55aaedf1ace620b0338f38147b40f5 | f9639a30fef6d9490b0faf4fbe740a8f4f960e88 | refs/heads/main | 2023-02-11T10:39:56.846198 | 2021-01-05T11:33:49 | 2021-01-05T11:33:49 | 314,114,840 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,480 | java | package com.blog.entity;
public class UserRanking {
private int user_id;
private String user_name;
private String user_profile_photo;
private int likeCounter;
@Override
public String toString() {
return "UserRanking{" +
"user_id=" + user_id +
", user_name='" + user_name + '\'' +
", user_profile_photo='" + user_profile_photo + '\'' +
", likeCounter=" + likeCounter +
'}';
}
public UserRanking() {
}
public UserRanking(int user_id, String user_name, String user_profile_photo, int likeCounter) {
this.user_id = user_id;
this.user_name = user_name;
this.user_profile_photo = user_profile_photo;
this.likeCounter = likeCounter;
}
public int getUser_id() {
return user_id;
}
public void setUser_id(int user_id) {
this.user_id = user_id;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getUser_profile_photo() {
return user_profile_photo;
}
public void setUser_profile_photo(String user_profile_photo) {
this.user_profile_photo = user_profile_photo;
}
public int getLikeCounter() {
return likeCounter;
}
public void setLikeCounter(int likeCounter) {
this.likeCounter = likeCounter;
}
}
| [
"[email protected]"
] | |
e4f91c9d686aa27040b52cf60a536ac9ab233fc3 | 3c59c21350a9d87519a7707d02d4b59decfa2e09 | /org.geocraft.ui.chartviewer/src/org/geocraft/ui/chartviewer/ChartUtil.java | 10d40a1b6591e63a28ebb5f8dd2aa30714eb08f2 | [] | no_license | duncanchild/geocraft | e7455751b4d3dcf0b17979fa8f0cabdacb2cc109 | b301c0c96ebfeaf36b8a0ec141f342cfc91c0ecb | refs/heads/master | 2021-01-15T08:05:36.041473 | 2015-05-15T17:17:30 | 2015-05-15T17:17:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 600 | java | /*
* Copyright (C) ConocoPhillips 2008 All Rights Reserved.
*/
package org.geocraft.ui.chartviewer;
import org.eclipse.swt.graphics.RGB;
import org.geocraft.ui.plot.defs.PointStyle;
public class ChartUtil {
public static RGB createRandomRGB() {
int r = (int) (Math.random() * 256);
int g = (int) (Math.random() * 256);
int b = (int) (Math.random() * 256);
return new RGB(r, g, b);
}
public static PointStyle createRandomPointStyle() {
PointStyle[] styles = PointStyle.values();
int index = (int) (Math.random() * styles.length);
return styles[index];
}
}
| [
"[email protected]"
] | |
714209e7ebf0ac72c12d48e9a6e4256ef499a62e | 14d5808bf7a36a316d014af9497594fa42ca93c1 | /doctor_xiaomi/src/main/java/com/shkjs/doctor/activity/CustomerServiceActivity.java | ed402ea5f2eaba713338e3687dbdda12f95afd58 | [] | no_license | Soon-gz/MySecondDemo | 3baa004b58043034d64c817bf49c071f17cb7687 | 36546731f4aef99ae29a26611277f4ce11361e2c | refs/heads/master | 2023-02-21T11:28:32.261133 | 2017-01-24T02:28:30 | 2017-01-24T02:28:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,995 | java | package com.shkjs.doctor.activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.raspberry.library.util.CustomAlertDialog;
import com.raspberry.library.util.DividerItemDecoration;
import com.shkjs.doctor.R;
import com.shkjs.doctor.base.BaseActivity;
import com.shkjs.doctor.base.BaseRecyclerAdapter;
import com.shkjs.doctor.base.BaseRecyclerViewHolder;
import com.shkjs.doctor.bean.QueryHelpBean;
import com.shkjs.doctor.http.HttpProtocol;
import com.shkjs.doctor.http.RaspberryCallback;
import com.shkjs.doctor.http.response.ListResponse;
import com.shkjs.doctor.util.AudioHelper;
import java.util.ArrayList;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class CustomerServiceActivity extends BaseActivity {
@Bind(R.id.toptitle_tv)
TextView toptitle_tv;
@Bind(R.id.custem_help_recyclerview)
RecyclerView custem_help_recyclerview;
private BaseRecyclerAdapter<QueryHelpBean>adapter;
private RaspberryCallback<ListResponse<QueryHelpBean>>callback;
private List<QueryHelpBean>dataList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer_service);
ButterKnife.bind(this);
toptitle_tv.setText("使用帮助");
initListener();
}
private void initListener() {
dataList = new ArrayList<>();
callback = new RaspberryCallback<ListResponse<QueryHelpBean>>() {
@Override
public void onSuccess(ListResponse<QueryHelpBean> response, int code) {
super.onSuccess(response, code);
if (HttpProtocol.checkStatus(response,code)){
dataList.addAll(response.getData());
adapter.notifyDataSetChanged();
}
}
};
AudioHelper.initCallBack(callback,this,true);
adapter = new BaseRecyclerAdapter<QueryHelpBean>(this,dataList) {
@Override
public int getItemLayoutId(int viewType) {
return R.layout.item_help;
}
@Override
public void bindData(BaseRecyclerViewHolder holder, int position, QueryHelpBean item) {
holder.getTextView(R.id.item_help_title).setText((position+1)+"."+item.getTitile());
holder.getTextView(R.id.item_help_content).setText(item.getContent());
if (item.getContent().contains("医星汇客服")){
holder.getTextView(R.id.item_help_content).setTextColor(getResources().getColor(R.color.red_e84618));
holder.getTextView(R.id.item_help_content).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CustomAlertDialog.dialogExSureCancel("是否给医星汇客服拨打电话?",CustomerServiceActivity.this, new CustomAlertDialog.OnDialogClickListener() {
@Override
public void doSomeThings() {
Intent intent = new Intent();
intent.setAction("android.intent.action.DIAL");
intent.setData(Uri.parse("tel:"+"4008859120"));
startActivity(intent);
}
});
}
});
}else {
holder.getTextView(R.id.item_help_content).setTextColor(getResources().getColor(R.color.gray_888888));
}
}
};
custem_help_recyclerview.setAdapter(adapter);
custem_help_recyclerview.setItemAnimator(new DefaultItemAnimator());
custem_help_recyclerview.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
custem_help_recyclerview.setHasFixedSize(true);
custem_help_recyclerview.setLayoutManager(new LinearLayoutManager(this));
HttpProtocol.getHelp(callback);
}
@OnClick(R.id.back_iv)
public void customerOnClick(View view){
switch (view.getId()){
case R.id.back_iv:
finish();
break;
// case R.id.customer_service_phone_call:
// Intent intent = new Intent();
// intent.setAction("android.intent.action.DIAL");
// intent.setData(Uri.parse("tel:"+customer_service_phone_call.getText().toString().trim()));
// startActivity(intent);
// break;
}
}
}
| [
"[email protected]"
] | |
e2b6e97de96f211d6672f1a12b7ce85419d8be9f | 0dccef976f19741f67479f32f15d76c1e90e7f94 | /bmz.java | f3f1467f474e2860dd79338efa3793f3e7e3e6ce | [] | no_license | Tominous/LabyMod-1.9 | a960959d67817b1300272d67bd942cd383dfd668 | 33e441754a0030d619358fc20ca545df98d55f71 | refs/heads/master | 2020-05-24T21:35:00.931507 | 2017-02-06T21:04:08 | 2017-02-06T21:04:08 | 187,478,724 | 1 | 0 | null | 2019-05-19T13:14:46 | 2019-05-19T13:14:46 | null | UTF-8 | Java | false | false | 20,615 | java | import com.google.common.primitives.Floats;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
import shadersmod.client.SVertexBuilder;
public class bmz
{
private static final Logger a = ;
private ByteBuffer b;
public IntBuffer c;
private ShortBuffer d;
public FloatBuffer e;
public int f;
private bvs g;
private int h;
private boolean i;
public int j;
private double k;
private double l;
private double m;
private bvr n;
private boolean o;
private ahm blockLayer = null;
private boolean[] drawnIcons = new boolean['Ā'];
private bvh[] quadSprites = null;
private bvh quadSprite = null;
public SVertexBuilder sVertexBuilder;
public bmz(int bufferSizeIn)
{
if (Config.isShaders()) {
bufferSizeIn *= 2;
}
this.b = bce.c(bufferSizeIn * 4);
this.c = this.b.asIntBuffer();
this.d = this.b.asShortBuffer();
this.e = this.b.asFloatBuffer();
SVertexBuilder.initVertexBuilder(this);
}
private void b(int p_181670_1_)
{
if (Config.isShaders()) {
p_181670_1_ *= 2;
}
int i = (this.f + 1) * this.n.g() + this.n.d(this.h);
if ((p_181670_1_ > this.c.remaining()) || (i >= this.b.capacity()))
{
int j = this.b.capacity();
int k = j % 2097152;
int l = k + (((this.c.position() + p_181670_1_) * 4 - k) / 2097152 + 1) * 2097152;
a.debug("Needed to grow BufferBuilder buffer: Old size " + j + " bytes, new size " + l + " bytes.");
int i1 = this.c.position();
ByteBuffer bytebuffer = bce.c(l);
this.b.position(0);
bytebuffer.put(this.b);
bytebuffer.rewind();
this.b = bytebuffer;
this.e = this.b.asFloatBuffer();
this.c = this.b.asIntBuffer();
this.c.position(i1);
this.d = this.b.asShortBuffer();
this.d.position(i1 << 1);
if (this.quadSprites != null)
{
bvh[] sprites = this.quadSprites;
int quadSize = getBufferQuadSize();
this.quadSprites = new bvh[quadSize];
System.arraycopy(sprites, 0, this.quadSprites, 0, Math.min(sprites.length, this.quadSprites.length));
}
}
}
public void a(float p_181674_1_, float p_181674_2_, float p_181674_3_)
{
int i = this.f / 4;
final float[] afloat = new float[i];
for (int j = 0; j < i; j++) {
afloat[j] = a(this.e, (float)(p_181674_1_ + this.k), (float)(p_181674_2_ + this.l), (float)(p_181674_3_ + this.m), this.n.f(), j * this.n.g());
}
Integer[] ainteger = new Integer[i];
for (int k = 0; k < ainteger.length; k++) {
ainteger[k] = Integer.valueOf(k);
}
Arrays.sort(ainteger, new Comparator()
{
public int a(Integer p_compare_1_, Integer p_compare_2_)
{
return Floats.compare(afloat[p_compare_2_.intValue()], afloat[p_compare_1_.intValue()]);
}
});
BitSet bitset = new BitSet();
int l = this.n.g();
int[] aint = new int[l];
for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < ainteger.length; l1++)
{
int i1 = ainteger[l1].intValue();
if (i1 != l1)
{
this.c.limit(i1 * l + l);
this.c.position(i1 * l);
this.c.get(aint);
int j1 = i1;
for (int k1 = ainteger[i1].intValue(); j1 != l1; k1 = ainteger[k1].intValue())
{
this.c.limit(k1 * l + l);
this.c.position(k1 * l);
IntBuffer intbuffer = this.c.slice();
this.c.limit(j1 * l + l);
this.c.position(j1 * l);
this.c.put(intbuffer);
bitset.set(j1);
j1 = k1;
}
this.c.limit(l1 * l + l);
this.c.position(l1 * l);
this.c.put(aint);
}
bitset.set(l1);
}
if (this.quadSprites != null)
{
bvh[] quadSpritesSorted = new bvh[this.f / 4];
int quadStep = this.n.g() / 4 * 4;
for (int ix = 0; ix < ainteger.length; ix++)
{
int indexQuad = ainteger[ix].intValue();
int indexQuadSorted = ix;
quadSpritesSorted[indexQuadSorted] = this.quadSprites[indexQuad];
}
System.arraycopy(quadSpritesSorted, 0, this.quadSprites, 0, quadSpritesSorted.length);
}
}
public bmz.a a()
{
this.c.rewind();
int i = j();
this.c.limit(i);
int[] aint = new int[i];
this.c.get(aint);
this.c.limit(this.c.capacity());
this.c.position(i);
bvh[] quadSpritesCopy = null;
if (this.quadSprites != null)
{
int countQuads = this.f / 4;
quadSpritesCopy = new bvh[countQuads];
System.arraycopy(this.quadSprites, 0, quadSpritesCopy, 0, countQuads);
}
return new bmz.a(aint, new bvr(this.n), quadSpritesCopy);
}
public int j()
{
return this.f * this.n.f();
}
private static float a(FloatBuffer p_181665_0_, float p_181665_1_, float p_181665_2_, float p_181665_3_, int p_181665_4_, int p_181665_5_)
{
float f = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 0);
float f1 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 1);
float f2 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 2);
float f3 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 0);
float f4 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 1);
float f5 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 2);
float f6 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 0);
float f7 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 1);
float f8 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 2);
float f9 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 0);
float f10 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 1);
float f11 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 2);
float f12 = (f + f3 + f6 + f9) * 0.25F - p_181665_1_;
float f13 = (f1 + f4 + f7 + f10) * 0.25F - p_181665_2_;
float f14 = (f2 + f5 + f8 + f11) * 0.25F - p_181665_3_;
return f12 * f12 + f13 * f13 + f14 * f14;
}
public void a(bmz.a state)
{
this.c.clear();
b(state.a().length);
this.c.put(state.a());
this.f = state.b();
this.n = new bvr(state.c());
if (state.stateQuadSprites != null)
{
if (this.quadSprites == null) {
this.quadSprites = new bvh[getBufferQuadSize()];
}
bvh[] src = state.stateQuadSprites;
System.arraycopy(src, 0, this.quadSprites, 0, src.length);
}
else
{
this.quadSprites = null;
}
}
public void b()
{
this.f = 0;
this.g = null;
this.h = 0;
this.quadSprite = null;
}
public void a(int glMode, bvr format)
{
if (this.o) {
throw new IllegalStateException("Already building!");
}
this.o = true;
b();
this.j = glMode;
this.n = format;
this.g = format.c(this.h);
this.i = false;
this.b.limit(this.b.capacity());
if (Config.isShaders()) {
SVertexBuilder.endSetVertexFormat(this);
}
if (Config.isMultiTexture())
{
if (this.blockLayer != null) {
if (this.quadSprites == null) {
this.quadSprites = new bvh[getBufferQuadSize()];
}
}
}
else {
this.quadSprites = null;
}
}
public bmz a(double p_187315_1_, double p_187315_3_)
{
if ((this.quadSprite != null) && (this.quadSprites != null))
{
p_187315_1_ = this.quadSprite.toSingleU((float)p_187315_1_);
p_187315_3_ = this.quadSprite.toSingleV((float)p_187315_3_);
this.quadSprites[(this.f / 4)] = this.quadSprite;
}
int i = this.f * this.n.g() + this.n.d(this.h);
switch (this.g.a())
{
case a:
this.b.putFloat(i, (float)p_187315_1_);
this.b.putFloat(i + 4, (float)p_187315_3_);
break;
case f:
case g:
this.b.putInt(i, (int)p_187315_1_);
this.b.putInt(i + 4, (int)p_187315_3_);
break;
case d:
case e:
this.b.putShort(i, (short)(int)p_187315_3_);
this.b.putShort(i + 2, (short)(int)p_187315_1_);
break;
case b:
case c:
this.b.put(i, (byte)(int)p_187315_3_);
this.b.put(i + 1, (byte)(int)p_187315_1_);
}
k();
return this;
}
public bmz a(int p_187314_1_, int p_187314_2_)
{
int i = this.f * this.n.g() + this.n.d(this.h);
switch (this.g.a())
{
case a:
this.b.putFloat(i, p_187314_1_);
this.b.putFloat(i + 4, p_187314_2_);
break;
case f:
case g:
this.b.putInt(i, p_187314_1_);
this.b.putInt(i + 4, p_187314_2_);
break;
case d:
case e:
this.b.putShort(i, (short)p_187314_2_);
this.b.putShort(i + 2, (short)p_187314_1_);
break;
case b:
case c:
this.b.put(i, (byte)p_187314_2_);
this.b.put(i + 1, (byte)p_187314_1_);
}
k();
return this;
}
public void a(int p_178962_1_, int p_178962_2_, int p_178962_3_, int p_178962_4_)
{
int i = (this.f - 4) * this.n.f() + this.n.b(1) / 4;
int j = this.n.g() >> 2;
this.c.put(i, p_178962_1_);
this.c.put(i + j, p_178962_2_);
this.c.put(i + j * 2, p_178962_3_);
this.c.put(i + j * 3, p_178962_4_);
}
public void a(double x, double y, double z)
{
int i = this.n.f();
int j = (this.f - 4) * i;
for (int k = 0; k < 4; k++)
{
int l = j + k * i;
int i1 = l + 1;
int j1 = i1 + 1;
this.c.put(l, Float.floatToRawIntBits((float)(x + this.k) + Float.intBitsToFloat(this.c.get(l))));
this.c.put(i1, Float.floatToRawIntBits((float)(y + this.l) + Float.intBitsToFloat(this.c.get(i1))));
this.c.put(j1, Float.floatToRawIntBits((float)(z + this.m) + Float.intBitsToFloat(this.c.get(j1))));
}
}
public int c(int p_78909_1_)
{
return ((this.f - p_78909_1_) * this.n.g() + this.n.e()) / 4;
}
public void a(float red, float green, float blue, int p_178978_4_)
{
int i = c(p_178978_4_);
int j = -1;
if (!this.i)
{
j = this.c.get(i);
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
{
int k = (int)((j & 0xFF) * red);
int l = (int)((j >> 8 & 0xFF) * green);
int i1 = (int)((j >> 16 & 0xFF) * blue);
j &= 0xFF000000;
j = j | i1 << 16 | l << 8 | k;
}
else
{
int j1 = (int)((j >> 24 & 0xFF) * red);
int k1 = (int)((j >> 16 & 0xFF) * green);
int l1 = (int)((j >> 8 & 0xFF) * blue);
j &= 0xFF;
j = j | j1 << 24 | k1 << 16 | l1 << 8;
}
}
this.c.put(i, j);
}
private void b(int argb, int p_178988_2_)
{
int i = c(p_178988_2_);
int j = argb >> 16 & 0xFF;
int k = argb >> 8 & 0xFF;
int l = argb & 0xFF;
int i1 = argb >> 24 & 0xFF;
a(i, j, k, l, i1);
}
public void b(float red, float green, float blue, int p_178994_4_)
{
int i = c(p_178994_4_);
int j = on.a((int)(red * 255.0F), 0, 255);
int k = on.a((int)(green * 255.0F), 0, 255);
int l = on.a((int)(blue * 255.0F), 0, 255);
a(i, j, k, l, 255);
}
public void a(int index, int red, int p_178972_3_, int p_178972_4_, int p_178972_5_)
{
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
this.c.put(index, p_178972_5_ << 24 | p_178972_4_ << 16 | p_178972_3_ << 8 | red);
} else {
this.c.put(index, red << 24 | p_178972_3_ << 16 | p_178972_4_ << 8 | p_178972_5_);
}
}
public void c()
{
this.i = true;
}
public bmz a(float red, float green, float blue, float alpha)
{
return b((int)(red * 255.0F), (int)(green * 255.0F), (int)(blue * 255.0F), (int)(alpha * 255.0F));
}
public bmz b(int red, int green, int blue, int alpha)
{
if (this.i) {
return this;
}
int i = this.f * this.n.g() + this.n.d(this.h);
switch (this.g.a())
{
case a:
this.b.putFloat(i, red / 255.0F);
this.b.putFloat(i + 4, green / 255.0F);
this.b.putFloat(i + 8, blue / 255.0F);
this.b.putFloat(i + 12, alpha / 255.0F);
break;
case f:
case g:
this.b.putFloat(i, red);
this.b.putFloat(i + 4, green);
this.b.putFloat(i + 8, blue);
this.b.putFloat(i + 12, alpha);
break;
case d:
case e:
this.b.putShort(i, (short)red);
this.b.putShort(i + 2, (short)green);
this.b.putShort(i + 4, (short)blue);
this.b.putShort(i + 6, (short)alpha);
break;
case b:
case c:
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
{
this.b.put(i, (byte)red);
this.b.put(i + 1, (byte)green);
this.b.put(i + 2, (byte)blue);
this.b.put(i + 3, (byte)alpha);
}
else
{
this.b.put(i, (byte)alpha);
this.b.put(i + 1, (byte)blue);
this.b.put(i + 2, (byte)green);
this.b.put(i + 3, (byte)red);
}
break;
}
k();
return this;
}
public void a(int[] vertexData)
{
if (Config.isShaders()) {
SVertexBuilder.beginAddVertexData(this, vertexData);
}
b(vertexData.length);
this.c.position(j());
this.c.put(vertexData);
this.f += vertexData.length / this.n.f();
if (Config.isShaders()) {
SVertexBuilder.endAddVertexData(this);
}
}
public void d()
{
this.f += 1;
b(this.n.f());
this.h = 0;
this.g = this.n.c(this.h);
if (Config.isShaders()) {
SVertexBuilder.endAddVertex(this);
}
}
public bmz b(double x, double y, double z)
{
if (Config.isShaders()) {
SVertexBuilder.beginAddVertex(this);
}
int i = this.f * this.n.g() + this.n.d(this.h);
switch (this.g.a())
{
case a:
this.b.putFloat(i, (float)(x + this.k));
this.b.putFloat(i + 4, (float)(y + this.l));
this.b.putFloat(i + 8, (float)(z + this.m));
break;
case f:
case g:
this.b.putInt(i, Float.floatToRawIntBits((float)(x + this.k)));
this.b.putInt(i + 4, Float.floatToRawIntBits((float)(y + this.l)));
this.b.putInt(i + 8, Float.floatToRawIntBits((float)(z + this.m)));
break;
case d:
case e:
this.b.putShort(i, (short)(int)(x + this.k));
this.b.putShort(i + 2, (short)(int)(y + this.l));
this.b.putShort(i + 4, (short)(int)(z + this.m));
break;
case b:
case c:
this.b.put(i, (byte)(int)(x + this.k));
this.b.put(i + 1, (byte)(int)(y + this.l));
this.b.put(i + 2, (byte)(int)(z + this.m));
}
k();
return this;
}
public void b(float x, float y, float z)
{
int i = (byte)(int)(x * 127.0F) & 0xFF;
int j = (byte)(int)(y * 127.0F) & 0xFF;
int k = (byte)(int)(z * 127.0F) & 0xFF;
int l = i | j << 8 | k << 16;
int i1 = this.n.g() >> 2;
int j1 = (this.f - 4) * i1 + this.n.c() / 4;
this.c.put(j1, l);
this.c.put(j1 + i1, l);
this.c.put(j1 + i1 * 2, l);
this.c.put(j1 + i1 * 3, l);
}
private void k()
{
this.h += 1;
this.h %= this.n.i();
this.g = this.n.c(this.h);
if (this.g.b() == bvs.b.g) {
k();
}
}
public bmz c(float p_181663_1_, float p_181663_2_, float p_181663_3_)
{
int i = this.f * this.n.g() + this.n.d(this.h);
switch (this.g.a())
{
case a:
this.b.putFloat(i, p_181663_1_);
this.b.putFloat(i + 4, p_181663_2_);
this.b.putFloat(i + 8, p_181663_3_);
break;
case f:
case g:
this.b.putInt(i, (int)p_181663_1_);
this.b.putInt(i + 4, (int)p_181663_2_);
this.b.putInt(i + 8, (int)p_181663_3_);
break;
case d:
case e:
this.b.putShort(i, (short)((int)(p_181663_1_ * 32767.0F) & 0xFFFF));
this.b.putShort(i + 2, (short)((int)(p_181663_2_ * 32767.0F) & 0xFFFF));
this.b.putShort(i + 4, (short)((int)(p_181663_3_ * 32767.0F) & 0xFFFF));
break;
case b:
case c:
this.b.put(i, (byte)((int)(p_181663_1_ * 127.0F) & 0xFF));
this.b.put(i + 1, (byte)((int)(p_181663_2_ * 127.0F) & 0xFF));
this.b.put(i + 2, (byte)((int)(p_181663_3_ * 127.0F) & 0xFF));
}
k();
return this;
}
public void c(double x, double y, double z)
{
this.k = x;
this.l = y;
this.m = z;
}
public void e()
{
if (!this.o) {
throw new IllegalStateException("Not building!");
}
this.o = false;
this.b.position(0);
this.b.limit(j() * 4);
}
public ByteBuffer f()
{
return this.b;
}
public bvr g()
{
return this.n;
}
public int h()
{
return this.f;
}
public int i()
{
return this.j;
}
public void a(int argb)
{
for (int i = 0; i < 4; i++) {
b(argb, i + 1);
}
}
public void d(float red, float green, float blue)
{
for (int i = 0; i < 4; i++) {
b(red, green, blue, i + 1);
}
}
public void putSprite(bvh sprite)
{
if (this.quadSprites == null) {
return;
}
int countQuads = this.f / 4;
this.quadSprites[(countQuads - 1)] = sprite;
}
public void setSprite(bvh sprite)
{
if (this.quadSprites == null) {
return;
}
this.quadSprite = sprite;
}
public boolean isMultiTexture()
{
return this.quadSprites != null;
}
public void drawMultiTexture()
{
if (this.quadSprites == null) {
return;
}
int maxTextureIndex = Config.getMinecraft().R().getCountRegisteredSprites();
if (this.drawnIcons.length <= maxTextureIndex) {
this.drawnIcons = new boolean[maxTextureIndex + 1];
}
Arrays.fill(this.drawnIcons, false);
int texSwitch = 0;
int grassOverlayIndex = -1;
int countQuads = this.f / 4;
for (int i = 0; i < countQuads; i++)
{
bvh icon = this.quadSprites[i];
if (icon != null)
{
int iconIndex = icon.getIndexInMap();
if (this.drawnIcons[iconIndex] == 0) {
if (icon == TextureUtils.iconGrassSideOverlay)
{
if (grassOverlayIndex < 0) {
grassOverlayIndex = i;
}
}
else
{
i = drawForIcon(icon, i) - 1;
texSwitch++;
if (this.blockLayer != ahm.d) {
this.drawnIcons[iconIndex] = true;
}
}
}
}
}
if (grassOverlayIndex >= 0)
{
drawForIcon(TextureUtils.iconGrassSideOverlay, grassOverlayIndex);
texSwitch++;
}
if (texSwitch > 0) {}
}
private int drawForIcon(bvh sprite, int startQuadPos)
{
GL11.glBindTexture(3553, sprite.glSpriteTextureId);
int firstRegionEnd = -1;
int lastPos = -1;
int countQuads = this.f / 4;
for (int i = startQuadPos; i < countQuads; i++)
{
bvh ts = this.quadSprites[i];
if (ts == sprite)
{
if (lastPos < 0) {
lastPos = i;
}
}
else if (lastPos >= 0)
{
draw(lastPos, i);
if (this.blockLayer == ahm.d) {
return i;
}
lastPos = -1;
if (firstRegionEnd < 0) {
firstRegionEnd = i;
}
}
}
if (lastPos >= 0) {
draw(lastPos, countQuads);
}
if (firstRegionEnd < 0) {
firstRegionEnd = countQuads;
}
return firstRegionEnd;
}
private void draw(int startQuadVertex, int endQuadVertex)
{
int vxQuadCount = endQuadVertex - startQuadVertex;
if (vxQuadCount <= 0) {
return;
}
int startVertex = startQuadVertex * 4;
int vxCount = vxQuadCount * 4;
GL11.glDrawArrays(this.j, startVertex, vxCount);
}
public void setBlockLayer(ahm blockLayer)
{
this.blockLayer = blockLayer;
if (blockLayer == null)
{
this.quadSprites = null;
this.quadSprite = null;
}
}
private int getBufferQuadSize()
{
int quadSize = this.c.capacity() * 4 / (this.n.g() * 4);
return quadSize;
}
public void checkAndGrow()
{
b(this.n.g());
}
public boolean isColorDisabled()
{
return this.i;
}
public class a
{
private final int[] b;
private final bvr c;
private bvh[] stateQuadSprites;
public a(int[] buffer, bvr format, bvh[] quadSprites)
{
this.b = buffer;
this.c = format;
this.stateQuadSprites = quadSprites;
}
public int[] a()
{
return this.b;
}
public int b()
{
return this.b.length / this.c.f();
}
public bvr c()
{
return this.c;
}
}
}
| [
"[email protected]"
] | |
39714f37d6f863d71efd3ef1d6f6ea1eced4da49 | 6c8ad50bd00929c478dff571823eb6d4eacc1913 | /src/main/java/pl/milk/aggregator/cache/GenreLazyCache.java | 30545c23b9e2e6652746095b49ec3d59689b14b7 | [] | no_license | projektMleko/aggregator | c18ffeb81cb76cccb58dee6f7897411f9c293df5 | b7f7576b828b193142d461e22e6a2b37c043171b | refs/heads/master | 2020-04-29T19:05:35.214797 | 2019-11-25T19:26:35 | 2019-11-25T19:26:35 | 176,343,754 | 2 | 1 | null | 2019-12-18T20:57:54 | 2019-03-18T18:11:18 | Java | UTF-8 | Java | false | false | 1,048 | java | package pl.milk.aggregator.cache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import pl.milk.aggregator.persistance.model.Genre;
import pl.milk.aggregator.persistance.repository.GenreRepository;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@Component
public class GenreLazyCache {
@Autowired
private GenreRepository genreRepository;
ConcurrentHashMap<String, Genre> genreMap = new ConcurrentHashMap<>();
@PostConstruct
private void initGenreMap() {
final List<Genre> allGenres = genreRepository.findAll();
allGenres.forEach(g -> genreMap.put(g.getName(), g));
}
public Genre getGenreForName(final String name) {
return genreMap.computeIfAbsent(name, this::addGenreForName);
}
private Genre addGenreForName(final String name) {
final Genre genre = new Genre();
genre.setName(name);
return genreRepository.save(genre);
}
}
| [
"[email protected]"
] | |
d72d4f28d19c927179962da163004d3c9af8b451 | 9761b2b2dc92fcc4fbd7c268a29599db2aa9ac92 | /HW1/Inermediate.java | 4fcf30c5d2f5523d38d03092a28c4db6336c7c71 | [
"MIT"
] | permissive | amazpyel/sqa_training | dca75d903c15dba6c03fc0c093592b7e6fd96c7e | c394b89ba3bf29bf958de00cdb3006090c51bbb4 | refs/heads/master | 2021-03-13T00:01:34.982368 | 2015-11-17T14:08:57 | 2015-11-17T14:08:57 | 23,519,905 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,636 | java | package HW1;
import java.util.Scanner;
/**
* Created with IntelliJ IDEA.
* Author: Oleksandr Pylkevych [email protected]
* Date: 9/1/14
* Time: 12:08 PM
* <p/>
* Description:
* - How many lucky tickets in the tickets package with numbers
* from 000001 till 999999 where the number is six decimal digits,
* and lucky is when the sum of the first three digits is equal to
* the sum of the last three digits?
* <p/>
* - User inputs natural number. Calculate sum of digits.
*/
public class Intermediate {
public static void main(String[] args) {
sumDigits();
System.out.println();
countLuckyTickets();
}
private static void countLuckyTickets() {
int count = 0;
for (int i = 1; i <= 999999; i++) {
int left = i / 100000 + i % 100000 / 10000 + i % 10000 / 1000;
int right = i % 1000 / 100 + i % 100 / 10 + i % 10;
if (left == right) {
count++;
}
}
System.out.println("Quantity of lucky tickets is " + count);
}
private static void sumDigits() {
Scanner userInput = new Scanner(System.in);
System.out.print("Please enter a number: ");
String number = userInput.next();
System.out.println("You entered " + number);
int sumDigits = 0;
int[] numberArray = new int[number.length()];
for (int i = 0; i < number.length(); i++) {
numberArray[i] = number.charAt(i) - '0';
sumDigits += numberArray[i];
}
System.out.println();
System.out.println("Sum of digits is " + sumDigits);
}
}
| [
"[email protected]"
] | |
8722f97492060ce2a482cf474c41101f78785262 | 4b3e1134b49a38e6b9ab2e912079ce60c462c2ec | /CaptureCamera/app/src/main/java/com/example/capturecamera/cameras/GlShader.java | 22e021bba0d935179c7b7db5b9ff87bb39030b4d | [] | no_license | daijinqiu/webrtcVideoCapture | 6323abb094ffc501cae76ae8cbec56300115af06 | ac9eea5430e7eee1ca99247e885d1ea4a38fdb08 | refs/heads/master | 2022-06-21T06:12:49.457281 | 2020-05-12T15:25:18 | 2020-05-12T15:25:18 | 260,463,265 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,258 | java | /*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package com.example.capturecamera.cameras;
import android.opengl.GLES20;
import java.nio.FloatBuffer;
import android.util.Log;
import com.example.capturecamera.opengl.EglBase;
// Helper class for handling OpenGL shaders and shader programs.
public class GlShader {
private static final String TAG = "GlShader";
private static int compileShader(int shaderType, String source) {
final int shader = GLES20.glCreateShader(shaderType);
if (shader == 0) {
throw new RuntimeException("glCreateShader() failed. GLES20 error: " + GLES20.glGetError());
}
GLES20.glShaderSource(shader, source);
GLES20.glCompileShader(shader);
int[] compileStatus = new int[] {GLES20.GL_FALSE};
GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
if (compileStatus[0] != GLES20.GL_TRUE) {
Log.e(TAG, "Compile error " + GLES20.glGetShaderInfoLog(shader) + " in shader:\n" + source);
throw new RuntimeException(GLES20.glGetShaderInfoLog(shader));
}
GlUtil.checkNoGLES2Error("compileShader");
return shader;
}
private int program;
public GlShader(String vertexSource, String fragmentSource) {
final int vertexShader = compileShader(GLES20.GL_VERTEX_SHADER, vertexSource);
final int fragmentShader = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
program = GLES20.glCreateProgram();
if (program == 0) {
throw new RuntimeException("glCreateProgram() failed. GLES20 error: " + GLES20.glGetError());
}
GLES20.glAttachShader(program, vertexShader);
GLES20.glAttachShader(program, fragmentShader);
GLES20.glLinkProgram(program);
int[] linkStatus = new int[] {GLES20.GL_FALSE};
GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
if (linkStatus[0] != GLES20.GL_TRUE) {
Log.e(TAG, "Could not link program: " + GLES20.glGetProgramInfoLog(program));
throw new RuntimeException(GLES20.glGetProgramInfoLog(program));
}
// According to the documentation of glLinkProgram():
// "After the link operation, applications are free to modify attached shader objects, compile
// attached shader objects, detach shader objects, delete shader objects, and attach additional
// shader objects. None of these operations affects the information log or the program that is
// part of the program object."
// But in practice, detaching shaders from the program seems to break some devices. Deleting the
// shaders are fine however - it will delete them when they are no longer attached to a program.
GLES20.glDeleteShader(vertexShader);
GLES20.glDeleteShader(fragmentShader);
GlUtil.checkNoGLES2Error("Creating GlShader");
}
public int getAttribLocation(String label) {
if (program == -1) {
throw new RuntimeException("The program has been released");
}
int location = GLES20.glGetAttribLocation(program, label);
if (location < 0) {
throw new RuntimeException("Could not locate '" + label + "' in program");
}
return location;
}
/**
* Enable and upload a vertex array for attribute |label|. The vertex data is specified in
* |buffer| with |dimension| number of components per vertex.
*/
public void setVertexAttribArray(String label, int dimension, FloatBuffer buffer) {
setVertexAttribArray(label, dimension, 0 /* stride */, buffer);
}
/**
* Enable and upload a vertex array for attribute |label|. The vertex data is specified in
* |buffer| with |dimension| number of components per vertex and specified |stride|.
*/
public void setVertexAttribArray(String label, int dimension, int stride, FloatBuffer buffer) {
if (program == -1) {
throw new RuntimeException("The program has been released");
}
int location = getAttribLocation(label);
GLES20.glEnableVertexAttribArray(location);
GLES20.glVertexAttribPointer(location, dimension, GLES20.GL_FLOAT, false, stride, buffer);
GlUtil.checkNoGLES2Error("setVertexAttribArray");
}
public int getUniformLocation(String label) {
if (program == -1) {
throw new RuntimeException("The program has been released");
}
int location = GLES20.glGetUniformLocation(program, label);
if (location < 0) {
throw new RuntimeException("Could not locate uniform '" + label + "' in program");
}
return location;
}
public void useProgram() {
if (program == -1) {
throw new RuntimeException("The program has been released");
}
synchronized (EglBase.lock) {
GLES20.glUseProgram(program);
}
GlUtil.checkNoGLES2Error("glUseProgram");
}
public void release() {
Log.d(TAG, "Deleting shader.");
// Delete program, automatically detaching any shaders from it.
if (program != -1) {
GLES20.glDeleteProgram(program);
program = -1;
}
}
}
| [
"[email protected]"
] | |
29e7801cbf6440daf38eedbbbd52dce8a3aef5e0 | fb6e50eacbf4315aec4577c6eaace1ef9dd80774 | /src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/ThreadPoolUtil.java | 76715ed9f376d91908a41c538bde929f1ac0a22c | [] | no_license | amitPa/jrs-rest-java-client | 1d7648d1f2ecd9d24931689c2bf6d3d84aa2f108 | 42043443a19666d6a6a6a32f59e332b73e09d94a | refs/heads/master | 2021-01-16T18:32:35.660969 | 2014-09-17T18:54:32 | 2014-09-17T18:54:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,447 | java | /*
* Copyright (C) 2005 - 2014 Jaspersoft Corporation. All rights reserved.
* http://www.jaspersoft.com.
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* 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/>.
*/
package com.jaspersoft.jasperserver.jaxrs.client.core;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class ThreadPoolUtil {
private static final ExecutorService executorService = Executors.newCachedThreadPool();
public synchronized static void runAsynchronously(RequestExecution requestExecutionTask){
Future<?> future = executorService.submit(requestExecutionTask.getTask());
requestExecutionTask.setFuture(future);
}
}
| [
"[email protected]"
] | |
18a7ce1be0f10d27e9d10d69388e0ba5d7181553 | b1d3a8fe68ccd5a54d69f2651142ba94fbfac91f | /tmp/src/java/com/mtutucv/ObterDados.java | de5d535ed0944cccc557bf0bcb877a4990e0b704 | [] | no_license | mtutucv/RestNotification | 1348b973b204a5fa57b1d1b90d40e2076c5b8954 | c0b3048d921c12312f30e30adca9b4c716dfe410 | refs/heads/master | 2021-01-13T15:17:50.049470 | 2016-12-15T21:16:27 | 2016-12-15T21:16:27 | 76,451,973 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,893 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mtutucv;
/**
*
* @author Mário Monteiro - 77910
*/
public class ObterDados {
private String logoUser; //Logotipo do Utilizador Autenticado
private String nomeUser; //Nome do Utilizador Autenticado
private String [] link; //conjunto de links da pagina
private String [] topEmpresas; //Ranking das empresas que fazem anuncios
private String [] textoValores; //Texto dos dados apresentados
private int [] percentagemtopEmpresas; // Percenbtagem das empresas que fazem anuncios
private int [] valores; // Valor numerico dos dados apresentados
private String [] percemtagemValores; //Percentagem semanais e darios dos dados apresentados
public ObterDados(int auth,String autKey){
this.link = new String[5];
this.topEmpresas = new String[5];
this.textoValores = new String[6];
this.percentagemtopEmpresas = new int[5];
this.valores = new int[6];
this.percemtagemValores = new String[6];
for(int i=0; i < this.textoValores.length; i++)
this.textoValores[i] = EnumString.getTitleByNumber(i + 1);
if (auth == 1) {
for(int i=0; i < this.link.length; i++)
this.link[i] = EnumString.getNamePageByNumber(i + 1);
for(int i=0; i < this.topEmpresas.length; i++)
this.topEmpresas[i] = "";
for(int i=0; i < this.percentagemtopEmpresas.length; i++)
this.percentagemtopEmpresas[i] = 0;
Library.getTop5Anunciantes(autKey,topEmpresas,percentagemtopEmpresas);
String dadosTotal = Library.obterTotalUtilizadores(autKey);
String dadosTotalSemanal = Library.obterTotalUtilizadoresSemanal(autKey);
String totalAnuncios = Library.getTotalAnuncio(autKey);
String totalAnunciosSemanal = Library.getTotalAnuncioSemanal(autKey);
double percentagemValoresAnunciosSemanal = 0;
int totalAnunciosPendentes = Library.countPublicidadePendentes(FilesConfig.publicidadeJSON);
double percentagemAnunciosPendentesSemanal=0;
if(!totalAnuncios.equals("0"))
percentagemValoresAnunciosSemanal = Double.parseDouble(totalAnunciosSemanal) * 100 / Double.parseDouble(totalAnuncios);
if(totalAnunciosPendentes != 0)
percentagemAnunciosPendentesSemanal = Double.parseDouble(String.valueOf(Library.countPublicidadePendentesLastWeek(FilesConfig.publicidadeJSON))) * 100 / Double.parseDouble(String.valueOf(totalAnunciosPendentes));
double [] percentagemV = Library.getPercentagemSemanal(dadosTotal, dadosTotalSemanal, 4);
String [] d = dadosTotal.split(",");
int [] val = {Integer.parseInt(d[0]),Integer.parseInt(d[1]),Integer.parseInt(d[2]),Integer.parseInt(d[3]),Integer.parseInt(totalAnuncios),totalAnunciosPendentes};
this.valores = val;
String [] percemtVal = {Library.roud2Decimal(percentagemV[0]),Library.roud2Decimal(percentagemV[1]),Library.roud2Decimal(percentagemV[2]),Library.roud2Decimal(percentagemV[3]),Library.roud2Decimal(percentagemValoresAnunciosSemanal),Library.roud2Decimal(percentagemAnunciosPendentesSemanal)};
this.percemtagemValores = percemtVal;
} else {
if(auth == 2)
{
for(int i=0; i < this.link.length; i++)
this.link[i] = EnumString.getNamePageByNumber(0);
this.link[1] = EnumString.getNamePageByNumber(2);
this.link[2] = EnumString.getNamePageByNumber(3);
}else
{
for(int i=0; i < this.link.length; i++)
this.link[i] = EnumString.getNamePageByNumber(0);
}
for(int i=0; i < this.topEmpresas.length; i++)
this.topEmpresas[i] = "";
for(int i=0; i < this.percentagemtopEmpresas.length; i++)
this.percentagemtopEmpresas[i] = 0;
for(int i=0; i < this.valores.length; i++)
this.valores[i] = 0;
for(int i=0; i < this.percemtagemValores.length; i++)
this.percemtagemValores[i] = "0";
}
}
public String[] getTopEmpresas() {
return topEmpresas;
}
public void setTopEmpresas(String[] topEmpresas) {
this.topEmpresas = topEmpresas;
}
public String[] getTextoValores() {
return textoValores;
}
public void setTextoValores(String[] textoValores) {
this.textoValores = textoValores;
}
public int[] getPercentagemtopEmpresas() {
return percentagemtopEmpresas;
}
public void setPercentagemtopEmpresas(int[] percentagemtopEmpresas) {
this.percentagemtopEmpresas = percentagemtopEmpresas;
}
public int[] getValores() {
return valores;
}
public void setValores(int[] valores) {
this.valores = valores;
}
public String [] getPercemtagemValores() {
return percemtagemValores;
}
public void setPercemtagemValores(String [] percemtagemValores) {
this.percemtagemValores = percemtagemValores;
}
public String[] getLink() {
return link;
}
public void setLink(String[] link) {
this.link = link;
}
public String getNomeUser() {
return nomeUser;
}
public void setNomeUser(String nomeUser) {
this.nomeUser = nomeUser;
}
public String getLogoUser() {
return logoUser;
}
public void setLogoUser(String logoUser) {
this.logoUser = logoUser;
}
}
| [
"[email protected]"
] | |
94bf03b230adf9acb787a8a3337084c889b65d11 | 542eaf9015ffcb3087e79bf542892d68fb12ab33 | /hadoop_yxd_hdfs/src/main/java/hadoop/beifeng/learn/WCMapReduce.java | 178134d88248894469ea70c7e23fd80d4bd39ac0 | [] | no_license | yxdongshine/hadoopyxdlearn | efee913c45443ad0005c8f4d57484d164dd728fd | 278c7ab30b5a8759fbdd27db4d37414be84485d2 | refs/heads/master | 2021-01-12T12:08:41.501588 | 2017-03-23T07:45:37 | 2017-03-23T07:45:37 | 72,318,982 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,718 | java | package hadoop.beifeng.learn;
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
public class WCMapReduce extends Configured implements Tool {
// step 1 : Mapper Class
public static class WCMapper extends
Mapper<LongWritable, Text, Text, IntWritable> {
// 输出单词
private Text mapOutputKey = new Text();
// 出现一次就记做1次
private IntWritable mapOutputValue = new IntWritable(1);
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
System.out.println("map-in-0-key: " + key.get() + " -- "
+ "map-in-value: " + value.toString());
// line value
// 获取文件每一行的<key,value>
String lineValue = value.toString();
// split
// 分割单词,以空格分割
// String[] strs = lineValue.split(" ");
StringTokenizer stringTokenizer = new StringTokenizer(lineValue);
while (stringTokenizer.hasMoreTokens()) {
// set map output key
mapOutputKey.set(stringTokenizer.nextToken());
// output
context.write(mapOutputKey, mapOutputValue);
}
// iterator
// 将数组里面的每一个单词拿出来,一个个组成<key,value>
// 生成1
/**
* for (String str : strs) { // 设置key // set map output key
* mapOutputKey.set(str);
*
* // output // 最终输出 context.write(mapOutputKey, mapOutputValue); }
*/
}
}
// step 2: Reducer Class
public static class WCReducer extends
Reducer<Text, IntWritable, Text, IntWritable> {
private IntWritable outputValue = new IntWritable();
@Override
protected void reduce(Text key, Iterable<IntWritable> values,
Context context) throws IOException, InterruptedException {
// temp : sum
// 定义一个临时变量
int sum = 0;
// iterator
// 对于迭代器中的值进行迭代累加,最后sum加完以后就是统计的次数
for (IntWritable value : values) {
// total
sum += value.get();
}
// set output value
outputValue.set(sum);
// output
context.write(key, outputValue);
}
}
/**
*
* @param args
* @return
* @throws Exception
* int run(String [] args) throws Exception;
*/
// step 3: Driver
public int run(String[] args) throws Exception {
Configuration configuration = this.getConf();
Job job = Job.getInstance(configuration, this.getClass()
.getSimpleName());
job.setJarByClass(WCMapReduce.class);
// set job
// input
Path inpath = new Path(args[0]);
FileInputFormat.addInputPath(job, inpath);
// output
Path outPath = new Path(args[1]);
FileOutputFormat.setOutputPath(job, outPath);
// Mapper
job.setMapperClass(WCMapper.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);
// ================shuffle=====================
// 1.partitioner
//job.setPartitionerClass(cls);
// 2.sort
// job.setSortComparatorClass(cls);
// 3.combiner
// job.setCombinerClass(WordCountCombiner.class);
// 4.group
// job.setGroupingComparatorClass(cls);
// ================shuffle=====================
// Reducer
job.setReducerClass(WCReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
//reduce number
//job.setNumReduceTasks(tasks);
// submit job
boolean isSuccess = job.waitForCompletion(true);
return isSuccess ? 0 : 1;
}
public static void main(String[] args) throws Exception {
Configuration configuration = new Configuration();
configuration.set("mapreduce.map.output.compress", "true");
configuration.set("mapreduce.map.output.compress.codec",
"org.apache.hadoop.io.compress.SnappyCodec");
/**
* // 传递两个参数,设置路径 args = new String[] {
* "hdfs://hadoop-senior01.ibeifeng.com:8020/user/beifeng/input",
* "hdfs://hadoop-senior01.ibeifeng.com:8020/user/beifeng/output3" };
*
* // run job int status = new WCMapReduce().run(args);
*
* System.exit(status);
*/
// run job
int status = ToolRunner.run(configuration, new WCMapReduce(), args);
// exit program
System.exit(status);
}
}
| [
"[email protected]"
] | |
8f31841c4ceab4c8cba00ec8540c5396d134d164 | d577f066627703130e70c60374d1b65f31072b43 | /World/Nether/LavaRiverGenerator.java | f82e16ad8da2e59ad1ab819723d8fd68b9e7fa41 | [] | no_license | lrivera25/ChromatiCraft | bef7960c1d81af29883a5d909cac8b652e38aac1 | 42842ad41ea3f8b2663f9dc19cb0b8983f64545e | refs/heads/master | 2021-03-24T05:35:43.135925 | 2020-03-14T20:50:10 | 2020-03-14T20:50:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,650 | java | /*******************************************************************************
* @author Reika Kalseki
*
* Copyright 2017
*
* All rights reserved.
* Distribution of the software in any form is only allowed with
* explicit, prior permission from the owner.
******************************************************************************/
package Reika.ChromatiCraft.World.Nether;
import java.util.Random;
import com.xcompwiz.mystcraft.api.world.logic.IPopulate;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import Reika.ChromatiCraft.Block.Worldgen.BlockStructureShield.BlockType;
import Reika.ChromatiCraft.Registry.ChromaBlocks;
import Reika.DragonAPI.ASM.APIStripper.Strippable;
import Reika.DragonAPI.Auxiliary.WorldGenInterceptionRegistry;
import Reika.DragonAPI.Instantiable.Data.Immutable.BlockKey;
import Reika.DragonAPI.Instantiable.Data.Maps.ThresholdMapping;
import Reika.DragonAPI.Instantiable.Event.SetBlockEvent;
import Reika.DragonAPI.Instantiable.Math.SimplexNoiseGenerator;
import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
@Strippable(value="com.xcompwiz.mystcraft.api.world.logic.IPopulate")
public class LavaRiverGenerator implements IPopulate {
private static final double RIVER_THRESH = 0.2;
private static final double RIVER_CENTER_THRESH = 0.1;
private static final double MIN_HEIGHT = 127;
private static final double MAX_HEIGHT = 240;
private static final ThresholdMapping<Block> blockTypes = new ThresholdMapping();
public final long seed;
private final BlockKey structBlock;
private final BlockKey fluidBlock;
private final SimplexNoiseGenerator placementNoise;
private final SimplexNoiseGenerator heightNoise;
//sometimes lava, sometimes pyrotheum
private final SimplexNoiseGenerator blockNoise;
public LavaRiverGenerator(long seed) {
this(seed, null, null);
}
public LavaRiverGenerator(long seed, BlockKey struct, BlockKey fluid) {
this.seed = seed;
placementNoise = new SimplexNoiseGenerator(seed);
heightNoise = new SimplexNoiseGenerator(-seed);
blockNoise = new SimplexNoiseGenerator(~seed);
structBlock = struct != null ? struct : new BlockKey(ChromaBlocks.STRUCTSHIELD.getBlockInstance(), BlockType.STONE.metadata);
fluidBlock = fluid;
}
static {
addFluid(20, "pyrotheum");
addFluid(80, Blocks.flowing_lava);
addFluid(40, "ic2pahoehoelava");
addFluid(5, "iron.molten");
addFluid(3, "gold.molten");
addFluid(2, "ardite.molten");
addFluid(2, "cobalt.molten");
addFluid(4, "obsidian.molten");
addFluid(10, "poison");
addFluid(1, "fluiddeath");
}
private static void addFluid(double weight, String s) {
Fluid f = FluidRegistry.getFluid(s);
if (f != null && f.canBePlacedInWorld()) {
addFluid(weight, f.getBlock());
}
}
private static void addFluid(double weight, Block b) {
blockTypes.addMapping(weight+blockTypes.lastValue(), b);
}
public void generate(World world, int chunkX, int chunkZ) {
WorldGenInterceptionRegistry.skipLighting = true;
SetBlockEvent.eventEnabledPre = false;
SetBlockEvent.eventEnabledPost = false;
for (int i = 0; i < 16; i++) {
for (int k = 0; k < 16; k++) {
int dx = chunkX*16+i;
int dz = chunkZ*16+k;
double rx = dx/32D;
double rz = dz/32D;
double val = Math.abs(placementNoise.getValue(rx, rz));
if (val <= RIVER_THRESH) {
double h = ReikaMathLibrary.normalizeToBounds(heightNoise.getValue(rx/8, rz/8), MIN_HEIGHT, MAX_HEIGHT);
int y = (int)h;
if (val < RIVER_CENTER_THRESH) {
for (int j = 0; j < 1; j++) {
int dy = y+j;
world.setBlock(dx, dy, dz, structBlock.blockID, structBlock.metadata, 2);
}
for (int j = 1; j <= 1; j++) {
int dy = y+j;
world.setBlock(dx, dy, dz, this.getLiquid(rx, rz), 0, 11);
}
}
else {
for (int j = 0; j < 3; j++) {
int dy = y+j;
world.setBlock(dx, dy, dz, structBlock.blockID, structBlock.metadata, 2);
}
}
}
}
}
WorldGenInterceptionRegistry.skipLighting = false;
SetBlockEvent.eventEnabledPre = true;
SetBlockEvent.eventEnabledPost = true;
}
private Block getLiquid(double rx, double rz) {
if (fluidBlock != null)
return fluidBlock.blockID;
double t = ReikaMathLibrary.normalizeToBounds(blockNoise.getValue(rx, rz), 0, blockTypes.lastValue());
return blockTypes.getForValue(t, true);
}
@Override
public boolean populate(World world, Random rand, int x, int z, boolean flag) {
this.generate(world, x >> 4, z >> 4);
return true;
}
}
| [
"[email protected]"
] | |
8c3956e52d65a5813450e3a72179c2bbda979124 | 470a5e25463ccf5326c21ebabb838f8e10334138 | /cloud/src/main/java/cloud/connect/CloudKafkaConnectIn.java | 21f0a575a2a4c1c7623c31080196db733b920715 | [
"Apache-2.0"
] | permissive | zwbwpqoi/iot-edge-cloud-fusion | 5f99600806aaf39aad3757f38c9e309e96b3be4d | b08fd051144c3025b6aec4f9d9de438d4b2e3cf2 | refs/heads/main | 2023-04-09T18:54:23.697914 | 2021-05-18T12:15:00 | 2021-05-18T12:15:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,684 | java | package cloud.connect;
import akka.actor.typed.ActorRef;
import cloud.bean.KafkaMsgList;
import cloud.global.GlobalKafkaConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import base.model.bean.BasicCommon;
import base.model.connect.bean.KafkaConfig;
import base.model.connect.bean.KafkaMsg;
import java.time.Duration;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
/**
* @author :LLH
* @date :Created in 2021/4/16 15:42
* @description:kafka 接入数据
*/
public class CloudKafkaConnectIn {
private static Logger logger = Logger.getLogger(CloudKafkaConnectIn.class.getName());
private ActorRef<BasicCommon> ref;
KafkaConsumer<String, String> consumer;
public CloudKafkaConnectIn(ActorRef<BasicCommon> ref) {
this.ref = ref;
init();
}
private void init() {
Properties kafkaPropertie = new Properties();
//配置broker地址,配置多个容错
kafkaPropertie.put("bootstrap.servers", "192.168.123.131:9092");
//配置key-value允许使用参数化类型,反序列化
kafkaPropertie.put("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
kafkaPropertie.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
//指定消费者所属的群组
kafkaPropertie.put("group.id","1");
//创建KafkaConsumer,将kafkaPropertie传入。
consumer = new KafkaConsumer<String, String>(kafkaPropertie);
Pattern pattern = Pattern.compile(GlobalKafkaConfig.cloud_in_topic);
consumer.subscribe(pattern);
logger.log(Level.INFO, "EdgeKafkaConnectIn is listening..." + GlobalKafkaConfig.cloud_in_topic);
//轮询消息
while (true) {
//获取ConsumerRecords,一秒钟轮训一次
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(1000));
//消费消息,遍历records
// KafkaMsg outData = new KafkaMsg();
List<KafkaMsg> msgs = new ArrayList<>();
for (ConsumerRecord<String, String> r : records) {
KafkaMsg data = new KafkaMsg();
data.setTopic(r.topic());
data.setKey(r.key());
data.setValue(r.value());
msgs.add(data);
ref.tell(data);
System.out.println("kafkaConnectIn " + r.topic() + ":" + r.key() + ":" + r.value());
}
}
}
}
| [
"[email protected]"
] | |
8755317af517b6011063f484e744aa783f2a68bb | 03db0e0a92dba86724fe6fa9f9c4394b4eb71fd7 | /src/main/java/com/github/shemnon/deckcontrol/Deck.java | aa40ee273ec33153c49dcfe76132e134a7fb48cd | [] | no_license | Xanaxiel/DeckControl | e7e61e13e76f08a401fa993b967a007b43ce01df | 86a2ae21fc8155dec553b8a555cd5a06a3b4496e | refs/heads/master | 2021-02-16T09:22:29.212130 | 2013-09-20T13:51:36 | 2013-09-20T13:51:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,111 | java | package com.github.shemnon.deckcontrol;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Control;
/**
* Created with IntelliJ IDEA.
* User: Danno Ferrin
* Date: 27 Aug 2012
* Time: 5:43 PM
*/
public class Deck extends Control {
private ListProperty<Node> nodes = new SimpleListProperty<>(this, "nodes", FXCollections.<Node>observableArrayList());
private IntegerProperty primaryNodeIndex = new SimpleIntegerProperty(this, "primaryNodeIndex", -1);
private ObjectProperty<Pos> alignment = new SimpleObjectProperty<>(this, "alignment", null);
public Deck() {
getStyleClass().add("deck");
}
public ObservableList<Node> getNodes() {
return nodes.get();
}
public void setNodes(ObservableList<Node> nodes) {
this.nodes.set(nodes);
}
public ListProperty<Node> nodesProperty() {
return nodes;
}
public int getPrimaryNodeIndex() {
return primaryNodeIndex.get();
}
public void setPrimaryNodeIndex(int primaryNodeIndex) {
this.primaryNodeIndex.set(primaryNodeIndex);
}
public IntegerProperty primaryNodeIndexProperty() {
return primaryNodeIndex;
}
public Pos getAlignment() {
return alignment.get();
}
public void setAlignment(Pos alignment) {
this.alignment.set(alignment);
}
public ObjectProperty<Pos> alignmentProperty() {
return alignment;
}
@Override
protected String getUserAgentStylesheet() {
return getClass().getResource("/com/github/shemnon/deckcontrol/" + this.getClass().getSimpleName() + ".css").toString();
}
public void nextNode() {
if (primaryNodeIndex.get() + 1 < nodes.size()) {
primaryNodeIndex.set(primaryNodeIndexProperty().get() + 1);
}
}
public void previousNode() {
if (primaryNodeIndex.get() > 0) {
primaryNodeIndex.set(primaryNodeIndexProperty().get() - 1);
}
}
}
| [
"[email protected]"
] | |
baf041466d82e8412a12834b716f2a847a6ed7f0 | 3c7ee39c25dccffc08f7f887799251f3c035567d | /src/main/java/evolver/traits/Trait.java | 91f2ed0e7b1073b36fbe3199fbfb5ccff9070128 | [] | no_license | kemlo77/graphical-evolver | 76a3de92fbb24dcfba682e77d83550b5fcac6938 | 024f054afb9e89a430af73abfa7195c9e3ab7734 | refs/heads/master | 2020-04-23T22:21:22.788913 | 2019-09-21T20:20:32 | 2019-09-21T20:20:32 | 171,498,679 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,821 | java | package evolver.traits;
import evolver.TargetImage;
import evolver.Utils;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.util.Locale;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public abstract class Trait {
private Color color;
private Color oldColor;
private Point pointThatWasMutated;
private int deltaX = 0;
private int deltaY = 0;
private boolean dead = false;
Trait() {
int r = ThreadLocalRandom.current().nextInt(0, 255);
int g = ThreadLocalRandom.current().nextInt(0, 255);
int b = ThreadLocalRandom.current().nextInt(0, 255);
this.color = new Color(r, g, b, 10);
}
public abstract void mutateShape(float degree);
public abstract void removeLastShapeMutation();
public abstract void draw(Graphics2D graphics);
public abstract String toSvg();
public void setDead() {
this.dead = true;
}
public boolean isDead() {
return this.dead;
}
Color getColor() {
return this.color;
}
void setColor(Color color) {
this.color = color;
}
/**
* A method that will mutate the color.
*
* @param degree The degree of mutation.
*/
public void mutateColor(float degree) {
oldColor = color;
Random rand = new Random();
final int slumpNr = rand.nextInt(5);
int newR = color.getRed();
int newG = color.getGreen();
int newB = color.getBlue();
int newAlpha = color.getAlpha();
switch (slumpNr) {
case 0:
newR = Utils.mutateInInterval(0, 255, color.getRed(), degree);
break;
case 1:
newG = Utils.mutateInInterval(0, 255, color.getGreen(), degree);
break;
case 2:
newB = Utils.mutateInInterval(0, 255, color.getBlue(), degree);
break;
case 3:
newAlpha = Utils.mutateInInterval(0, 255, color.getAlpha(), degree);
break;
case 4:
newR = Utils.mutateInInterval(0, 255, color.getRed(), degree);
newG = Utils.mutateInInterval(0, 255, color.getGreen(), degree);
newB = Utils.mutateInInterval(0, 255, color.getBlue(), degree);
newAlpha = Utils.mutateInInterval(0, 255, color.getAlpha(), degree);
break;
default:
break;
}
color = new Color(newR, newG, newB, newAlpha);
}
/**
* Removes the mutation of the color.
*/
public void removeLastColorMutation() {
if (oldColor != null) {
color = oldColor;
oldColor = null;
}
}
Point generateRandomPoint() {
int x = ThreadLocalRandom.current().nextInt(0, TargetImage.getImageWidth() + 1);
int y = ThreadLocalRandom.current().nextInt(0, TargetImage.getImageHeight() + 1);
return new Point(x, y);
}
void mutatePoint(Point pointToBeMutated, float degree) {
int currentX = (int) pointToBeMutated.getX();
int currentY = (int) pointToBeMutated.getY();
//TODO: skriv om detta så att det är tillåtet att deltaX xor deltaY slumpas till 0
//ok för koordinater, men inte för färger
//alltså kanske skriva om mutateInInterval
deltaX = Utils.mutateInInterval(0, TargetImage.getImageWidth(), currentX, degree) - currentX;
deltaY = Utils.mutateInInterval(0, TargetImage.getImageHeight(), currentY, degree) - currentY;
pointToBeMutated.translate(deltaX, deltaY);
pointThatWasMutated = pointToBeMutated;
}
void removeLastPointMutation() {
if (pointThatWasMutated != null) {
pointThatWasMutated.translate(-deltaX, -deltaY);
deltaX = 0;
deltaY = 0;
}
}
String svgColorInfo() {
return
"\"rgb("
+ color.getRed() + ","
+ color.getGreen() + ","
+ color.getBlue() + ")\" "
+ "opacity=\""
+ String.format(Locale.ROOT, "%.3f", color.getAlpha() / 255f) + "\" ";
}
} | [
"[email protected]"
] | |
9fe588263ecd9307be32ded21353795de0eb86f8 | 8b1a2bcf6ce41737d243f6a57be5e68b2e7362e5 | /src/main/java/com/preving/springboot/backend/apirest/TiendaOnlineBackendApiApplication.java | 163c722f7f57882f10edc0c54aead4f600da816c | [] | no_license | RubenOnivenis/tienda-online-back | 289bfd62eaa12df2d6dc31ece640df6c474092b2 | 847923ec333c6a95b1d967897eca092148bfb9a4 | refs/heads/master | 2023-04-13T13:48:07.345783 | 2021-03-11T13:51:27 | 2021-03-11T13:51:27 | 343,676,718 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 363 | java | package com.preving.springboot.backend.apirest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TiendaOnlineBackendApiApplication {
public static void main(String[] args) {
SpringApplication.run(TiendaOnlineBackendApiApplication.class, args);
}
}
| [
"[email protected]"
] | |
3b5fbf80bd24e6f04472a219bb66d4a178d0d98b | 731c5170fb85175dcc3432b438dfceb5c123c1f0 | /rental_bicycle_web/src/main/java/by/javatr/bicrent/action/impl/order_page/ActionFinishOrder.java | 2b335ce25294ca98c9b9278775dd6d0d10e49332 | [] | no_license | MariaGolownia/project | 3bf6004c92d10e6f6ba5092759663e90fff8c6ea | 8e712b99bb2433237945985939ab341396f82ef4 | refs/heads/master | 2022-12-26T06:27:13.534374 | 2020-01-26T15:25:01 | 2020-01-26T15:25:01 | 236,328,033 | 0 | 0 | null | 2022-12-16T04:51:05 | 2020-01-26T15:02:18 | Java | UTF-8 | Java | false | false | 2,086 | java | package by.javatr.bicrent.action.impl.order_page;
import by.javatr.bicrent.dao.mysql.DaoSql;
import by.javatr.bicrent.entity.Order;
import by.javatr.bicrent.service.FactoryService;
import by.javatr.bicrent.service.impl.BicycleServiceImpl;
import by.javatr.bicrent.service.impl.OrderServiceImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@WebServlet("/finishOrder/*")
public class ActionFinishOrder extends HttpServlet {
private static final Logger LOGGER = LogManager.getLogger();
public static final Boolean FREE_STATUS_TRUE = true;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
Integer orderId = Integer.valueOf(request.getParameter("idOrder"));
String finishTimeStr = "";
FactoryService factoryService = FactoryService.getInstance();
OrderServiceImpl userOrderService = factoryService.get(DaoSql.OrderDao);
String json = "";
finishTimeStr = userOrderService.setFinishTime(orderId);
response.setContentType("text/plain");
List<Integer> bicycleIdList = new ArrayList<>();
Order order = userOrderService.read(orderId);
bicycleIdList = order.getBicyclesId();
// Обращение для поиска велосипедов по idOrder
BicycleServiceImpl bicycleService = factoryService.get(DaoSql.BicycleDao);
bicycleService.changeFreeStatus(bicycleIdList, FREE_STATUS_TRUE);
try {
response.getWriter().write(finishTimeStr);
} catch (IOException e) {
LOGGER.error("IOException from ActionFinishOrder =" + e.getMessage());
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
doGet(request, response);
}
}
| [
"[email protected]"
] | |
88a4ee49b5cca286d468747dfac51dae78dc2303 | 9967c459f5bea4a6edf8f4421db45a9f78f91a10 | /src/main/java/lk/teachmeit/boilerplate/util/CORSFilter.java | 66eb4b51dd55e8b8c3135f0f06aa604b793506a4 | [] | no_license | vishwasri/springboot-jwt-boilerplate | 1d35e30e89adf30675f68eb26a872439328eeb90 | b2ac6bc6adfaa047ac5a0999001040da43b42c9f | refs/heads/master | 2023-06-24T02:22:35.781931 | 2021-07-20T08:59:18 | 2021-07-20T08:59:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 946 | java | package lk.teachmeit.boilerplate.util;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class CORSFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Origin, Accept, Access-Control-Request-Method, Access-Control-Request-Headers");
chain.doFilter(req, res);
}
public void init(FilterConfig filterConfig) {}
public void destroy() {}
}
| [
"[email protected]"
] | |
e1ccbeb3fef1b8ed6f5c5133a3ab5c79aedc336f | 49f0585f3de55bfd438b04a77125766b2e642bab | /src/main/java/com/pqtran/workspace/adventcalendar/day7/BagRuleParser.java | 1bfcf29c52466fc5fe85003a7ce25dc924065aef | [] | no_license | PQTran/advent2020 | 224b3dc7777e5429494380bbc95e4b82db5b7402 | b618dacd0dc633f4047efb754d7ea44dd65ee9f7 | refs/heads/master | 2023-01-31T05:00:36.047103 | 2020-12-11T10:47:39 | 2020-12-11T10:47:39 | 317,778,512 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,613 | java | package com.pqtran.workspace.adventcalendar.day7;
import java.lang.IllegalArgumentException;
import java.io.*;
import java.util.*;
import java.util.regex.*;
import com.pqtran.workspace.utility.ResourceFile;
import com.pqtran.workspace.adventcalendar.day7.BagGroup;
class BagRuleParser {
static Pattern bagQuantityPattern = Pattern.compile("([0-9]*).*");
// consider refactoring to simpler regex
static Pattern bagColorPattern = Pattern.compile("[0-9]*\\s?(.*?) bags?.*");
static Pattern bagListPattern = Pattern.compile(".* contain (.*).");
static Integer parseBagQuantity(String line) throws IllegalArgumentException {
Matcher bagQuantityMatcher = bagQuantityPattern.matcher(line);
if (!bagQuantityMatcher.matches())
throw new IllegalArgumentException("Unable to parse bag quantity");
return Integer.valueOf(bagQuantityMatcher.group(1));
}
static String parseBagColor(String line) throws IllegalArgumentException {
Matcher bagColorMatcher = bagColorPattern.matcher(line);
if (!bagColorMatcher.matches())
throw new IllegalArgumentException("Unable to parse bag color");
return bagColorMatcher.group(1);
}
static String[] parseBagList(String line) throws IllegalArgumentException {
Matcher bagListMatcher = bagListPattern.matcher(line);
if (!bagListMatcher.matches())
throw new IllegalArgumentException("Unable to parse list of bags");
return bagListMatcher.group(1).split(", ");
}
static Map<String, List<BagGroup>> getParentChildrenMapping(ResourceFile resourceFile) throws IOException, IllegalArgumentException {
Map<String, List<BagGroup>> mapping = new HashMap<>();
try (BufferedReader reader = resourceFile.getReader()) {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
List<BagGroup> children = new ArrayList<>();
String parentColor = parseBagColor(line);
if (line.indexOf("no other bags") != -1) {
mapping.put(parentColor, children);
continue;
}
String[] childrenBags = parseBagList(line);
for (String bagStr : childrenBags) {
String color = parseBagColor(bagStr);
Integer quantity = parseBagQuantity(bagStr);
children.add(new BagGroup(color, quantity));
}
mapping.put(parentColor, children);
}
}
return mapping;
}
}
| [
"[email protected]"
] | |
7de61aacae91707c5932be2c4b15ad46196f8c66 | 4b0bf4787e89bcae7e4759bde6d7f3ab2c81f849 | /aliyun-java-sdk-mpserverless/src/main/java/com/aliyuncs/mpserverless/model/v20190930/UpdateFunctionRequest.java | 73753aa1217f2a6105c6745ba091bdd4169f4102 | [
"Apache-2.0"
] | permissive | aliyun/aliyun-openapi-java-sdk | a263fa08e261f12d45586d1b3ad8a6609bba0e91 | e19239808ad2298d32dda77db29a6d809e4f7add | refs/heads/master | 2023-09-03T12:28:09.765286 | 2023-09-01T09:03:00 | 2023-09-01T09:03:00 | 39,555,898 | 1,542 | 1,317 | NOASSERTION | 2023-09-14T07:27:05 | 2015-07-23T08:41:13 | Java | UTF-8 | Java | false | false | 2,862 | java | /*
* 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.aliyuncs.mpserverless.model.v20190930;
import com.aliyuncs.RpcAcsRequest;
import com.aliyuncs.http.MethodType;
/**
* @author auto create
* @version
*/
public class UpdateFunctionRequest extends RpcAcsRequest<UpdateFunctionResponse> {
private String memory;
private String runtime;
private String timeout;
private String customVariables;
private String spaceId;
private String functionId;
private String functionDesc;
public UpdateFunctionRequest() {
super("MPServerless", "2019-09-30", "UpdateFunction", "MPServerless");
setMethod(MethodType.POST);
}
public String getMemory() {
return this.memory;
}
public void setMemory(String memory) {
this.memory = memory;
if(memory != null){
putBodyParameter("Memory", memory);
}
}
public String getRuntime() {
return this.runtime;
}
public void setRuntime(String runtime) {
this.runtime = runtime;
if(runtime != null){
putBodyParameter("Runtime", runtime);
}
}
public String getTimeout() {
return this.timeout;
}
public void setTimeout(String timeout) {
this.timeout = timeout;
if(timeout != null){
putBodyParameter("Timeout", timeout);
}
}
public String getCustomVariables() {
return this.customVariables;
}
public void setCustomVariables(String customVariables) {
this.customVariables = customVariables;
if(customVariables != null){
putBodyParameter("CustomVariables", customVariables);
}
}
public String getSpaceId() {
return this.spaceId;
}
public void setSpaceId(String spaceId) {
this.spaceId = spaceId;
if(spaceId != null){
putBodyParameter("SpaceId", spaceId);
}
}
public String getFunctionId() {
return this.functionId;
}
public void setFunctionId(String functionId) {
this.functionId = functionId;
if(functionId != null){
putBodyParameter("FunctionId", functionId);
}
}
public String getFunctionDesc() {
return this.functionDesc;
}
public void setFunctionDesc(String functionDesc) {
this.functionDesc = functionDesc;
if(functionDesc != null){
putBodyParameter("FunctionDesc", functionDesc);
}
}
@Override
public Class<UpdateFunctionResponse> getResponseClass() {
return UpdateFunctionResponse.class;
}
}
| [
"[email protected]"
] | |
39e6d94247ce0dca3f57a320ea251e0b2ec02107 | 39a6f4d5d094a1bbe422eb8cd14189d3ae810237 | /src/main/java/com/ouyangxizhu/design/pattern/creational/abstractfactory/Article.java | 593282a34e75deb0e254edfe44d18212754540f6 | [] | no_license | ouyangxizhu/design_pattern | 6d8ecb41b12f017e4f7feb390ef92090f3939463 | 45c8b151b63255f11e5c1949cc50dd54c0a83344 | refs/heads/master | 2022-12-24T04:44:48.071895 | 2019-08-14T15:29:33 | 2019-08-14T15:29:33 | 202,291,120 | 0 | 0 | null | 2022-12-16T03:47:21 | 2019-08-14T06:46:02 | Java | UTF-8 | Java | false | false | 166 | java | package com.ouyangxizhu.design.pattern.creational.abstractfactory;
/**
* Created by geely
*/
public abstract class Article {
public abstract void produce();
}
| [
"[email protected]"
] | |
a0c27b100013c6feaf107382aa635da3a8bb4f9f | f17d4ddff32ba25445e4593dae85b050391ee182 | /src/main/java/com/xuekai/algorithm/listnode/ListNodeReverse.java | 993367c0d4e7653cef7cb1722abe3224a1952508 | [] | no_license | shixk/javaDemo | 2e607c65eac48215f4c786e95b59491d94aca9d4 | 74a4817be7813b22e88fca4bd2551be42a7cd7f7 | refs/heads/master | 2023-04-13T11:22:37.366361 | 2023-03-29T09:59:53 | 2023-03-29T09:59:53 | 100,478,818 | 2 | 0 | null | 2022-12-16T03:13:01 | 2017-08-16T10:45:30 | Java | UTF-8 | Java | false | false | 2,047 | java | package com.xuekai.algorithm.listnode;
import com.xuekai.entity.ListNode;
/**
* @Author shixuekai
* @CreateDate 2021/2/3
* @Description
**/
public class ListNodeReverse {
//就地反转,双指针向前移动
private static ListNode reverse1(ListNode head){
ListNode dummy = new ListNode();
//先指向首位
dummy.setNext(head);
ListNode pCur = head.getNext();
ListNode prev = head;
//走到最后时,弹出
while (pCur != null){
prev.setNext(pCur.getNext());
pCur.setNext(dummy.getNext());
dummy.setNext(pCur);
pCur = prev.getNext();
}
//返回最新的指向
return dummy.getNext();
}
public static void main(String[] args) {
ListNode node4 = new ListNode();
node4.setValue(4);
node4.setNext(null);
ListNode node3 = new ListNode();
node3.setValue(4);
node3.setNext(node4);
ListNode node2 = new ListNode();
node2.setValue(4);
node2.setNext(node3);
ListNode node1 = new ListNode();
node1.setValue(4);
node1.setNext(node2);
printList(node1);
System.out.println("反转之后是");
// ListNode newList = reverse1(node1);
//printList(newList);
printList(deleteNode(node1,4));
}
private static void printList(ListNode node){
ListNode temp = node;
while (temp != null){
System.out.println(temp.getValue());
temp = temp.getNext();
}
}
private static ListNode deleteNode(ListNode head,int val){
ListNode dummy = new ListNode();
dummy.setNext(head);
ListNode temp = dummy;
while (temp.getNext()!=null){
if(temp.getNext().getValue() == val){
temp.getNext().setNext(temp.getNext().getNext());
}else {
temp = temp.getNext();
}
}
return dummy.getNext();
}
}
| [
"[email protected]"
] | |
1dd7dfa8b9823a3c5eb15b2a68683367ee292757 | 8304b492a73d07cbaf53379b8f2a944a3eb377e3 | /app/src/main/java/com/example/yaoobs/anothersample/AndroidSourceDesignPatternsAnalysisPractice/DiskLruCache.java | c6f740bb8cd0b1d825b622156fe580cff94c992b | [] | no_license | Yaoobs/AnotherSample | 1da165facb65c4e0a9bf5e0e2e0db2ae39bd3b77 | 2de40517f597ae495026136616b8e4086ba58a0e | refs/heads/master | 2021-10-29T00:36:22.467645 | 2019-04-26T09:05:48 | 2019-04-26T09:05:48 | 70,403,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 33,964 | java | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.yaoobs.anothersample.AndroidSourceDesignPatternsAnalysisPractice;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.Array;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
******************************************************************************
* Taken from the JB source code, can be found in:
* libcore/luni/src/main/java/libcore/io/DiskLruCache.java
* or direct link:
* https://android.googlesource.com/platform/libcore/+/android-4.1.1_r1/luni/src/main/java/libcore/io/DiskLruCache.java
******************************************************************************
*
* A cache that uses a bounded amount of space on a filesystem. Each cache
* entry has a string key and a fixed number of values. Values are byte
* sequences, accessible as streams or files. Each value must be between {@code
* 0} and {@code Integer.MAX_VALUE} bytes in length.
*
* <p>The cache stores its data in a directory on the filesystem. This
* directory must be exclusive to the cache; the cache may delete or overwrite
* files from its directory. It is an error for multiple processes to use the
* same cache directory at the same time.
*
* <p>This cache limits the number of bytes that it will store on the
* filesystem. When the number of stored bytes exceeds the limit, the cache will
* remove entries in the background until the limit is satisfied. The limit is
* not strict: the cache may temporarily exceed it while waiting for files to be
* deleted. The limit does not include filesystem overhead or the cache
* journal so space-sensitive applications should set a conservative limit.
*
* <p>Clients call {@link #edit} to create or update the values of an entry. An
* entry may have only one editor at one time; if a value is not available to be
* edited then {@link #edit} will return null.
* <ul>
* <li>When an entry is being <strong>created</strong> it is necessary to
* supply a full set of values; the empty value should be used as a
* placeholder if necessary.
* <li>When an entry is being <strong>edited</strong>, it is not necessary
* to supply data for every value; values default to their previous
* value.
* </ul>
* Every {@link #edit} call must be matched by a call to {@link Editor#commit}
* or {@link Editor#abort}. Committing is atomic: a read observes the full set
* of values as they were before or after the commit, but never a mix of values.
*
* <p>Clients call {@link #get} to read a snapshot of an entry. The read will
* observe the value at the time that {@link #get} was called. Updates and
* removals after the call do not impact ongoing reads.
*
* <p>This class is tolerant of some I/O errors. If files are missing from the
* filesystem, the corresponding entries will be dropped from the cache. If
* an error occurs while writing a cache value, the edit will fail silently.
* Callers should handle other problems by catching {@code IOException} and
* responding appropriately.
*/
public final class DiskLruCache implements Closeable {
static final String JOURNAL_FILE = "journal";
static final String JOURNAL_FILE_TMP = "journal.tmp";
static final String MAGIC = "libcore.io.DiskLruCache";
static final String VERSION_1 = "1";
static final long ANY_SEQUENCE_NUMBER = -1;
private static final String CLEAN = "CLEAN";
private static final String DIRTY = "DIRTY";
private static final String REMOVE = "REMOVE";
private static final String READ = "READ";
private static final Charset UTF_8 = Charset.forName("UTF-8");
private static final int IO_BUFFER_SIZE = 8 * 1024;
/*
* This cache uses a journal file named "journal". A typical journal file
* looks like this:
* libcore.io.DiskLruCache
* 1
* 100
* 2
*
* CLEAN 3400330d1dfc7f3f7f4b8d4d803dfcf6 832 21054
* DIRTY 335c4c6028171cfddfbaae1a9c313c52
* CLEAN 335c4c6028171cfddfbaae1a9c313c52 3934 2342
* REMOVE 335c4c6028171cfddfbaae1a9c313c52
* DIRTY 1ab96a171faeeee38496d8b330771a7a
* CLEAN 1ab96a171faeeee38496d8b330771a7a 1600 234
* READ 335c4c6028171cfddfbaae1a9c313c52
* READ 3400330d1dfc7f3f7f4b8d4d803dfcf6
*
* The first five lines of the journal form its header. They are the
* constant string "libcore.io.DiskLruCache", the disk cache's version,
* the application's version, the value count, and a blank line.
*
* Each of the subsequent lines in the file is a record of the state of a
* cache entry. Each line contains space-separated values: a state, a key,
* and optional state-specific values.
* o DIRTY lines track that an entry is actively being created or updated.
* Every successful DIRTY action should be followed by a CLEAN or REMOVE
* action. DIRTY lines without a matching CLEAN or REMOVE indicate that
* temporary files may need to be deleted.
* o CLEAN lines track a cache entry that has been successfully published
* and may be read. A publish line is followed by the lengths of each of
* its values.
* o READ lines track accesses for LRU.
* o REMOVE lines track entries that have been deleted.
*
* The journal file is appended to as cache operations occur. The journal may
* occasionally be compacted by dropping redundant lines. A temporary file named
* "journal.tmp" will be used during compaction; that file should be deleted if
* it exists when the cache is opened.
*/
private final File directory;
private final File journalFile;
private final File journalFileTmp;
private final int appVersion;
private final long maxSize;
private final int valueCount;
private long size = 0;
private Writer journalWriter;
private final LinkedHashMap<String, Entry> lruEntries
= new LinkedHashMap<String, Entry>(0, 0.75f, true);
private int redundantOpCount;
/**
* To differentiate between old and current snapshots, each entry is given
* a sequence number each time an edit is committed. A snapshot is stale if
* its sequence number is not equal to its entry's sequence number.
*/
private long nextSequenceNumber = 0;
/* From java.util.Arrays */
@SuppressWarnings("unchecked")
private static <T> T[] copyOfRange(T[] original, int start, int end) {
final int originalLength = original.length; // For exception priority compatibility.
if (start > end) {
throw new IllegalArgumentException();
}
if (start < 0 || start > originalLength) {
throw new ArrayIndexOutOfBoundsException();
}
final int resultLength = end - start;
final int copyLength = Math.min(resultLength, originalLength - start);
final T[] result = (T[]) Array
.newInstance(original.getClass().getComponentType(), resultLength);
System.arraycopy(original, start, result, 0, copyLength);
return result;
}
/**
* Returns the remainder of 'reader' as a string, closing it when done.
*/
public static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
reader.close();
}
}
/**
* Returns the ASCII characters up to but not including the next "\r\n", or
* "\n".
*
* @throws java.io.EOFException if the stream is exhausted before the next newline
* character.
*/
public static String readAsciiLine(InputStream in) throws IOException {
// TODO: support UTF-8 here instead
StringBuilder result = new StringBuilder(80);
while (true) {
int c = in.read();
if (c == -1) {
throw new EOFException();
} else if (c == '\n') {
break;
}
result.append((char) c);
}
int length = result.length();
if (length > 0 && result.charAt(length - 1) == '\r') {
result.setLength(length - 1);
}
return result.toString();
}
/**
* Closes 'closeable', ignoring any checked exceptions. Does nothing if 'closeable' is null.
*/
public static void closeQuietly(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException rethrown) {
throw rethrown;
} catch (Exception ignored) {
}
}
}
/**
* Recursively delete everything in {@code dir}.
*/
// TODO: this should specify paths as Strings rather than as Files
public static void deleteContents(File dir) throws IOException {
File[] files = dir.listFiles();
if (files == null) {
throw new IllegalArgumentException("not a directory: " + dir);
}
for (File file : files) {
if (file.isDirectory()) {
deleteContents(file);
}
if (!file.delete()) {
throw new IOException("failed to delete file: " + file);
}
}
}
/** This cache uses a single background thread to evict entries. */
private final ExecutorService executorService = new ThreadPoolExecutor(0, 1,
60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
private final Callable<Void> cleanupCallable = new Callable<Void>() {
@Override public Void call() throws Exception {
synchronized (DiskLruCache.this) {
if (journalWriter == null) {
return null; // closed
}
trimToSize();
if (journalRebuildRequired()) {
rebuildJournal();
redundantOpCount = 0;
}
}
return null;
}
};
private DiskLruCache(File directory, int appVersion, int valueCount, long maxSize) {
this.directory = directory;
this.appVersion = appVersion;
this.journalFile = new File(directory, JOURNAL_FILE);
this.journalFileTmp = new File(directory, JOURNAL_FILE_TMP);
this.valueCount = valueCount;
this.maxSize = maxSize;
}
/**
* Opens the cache in {@code directory}, creating a cache if none exists
* there.
*
* @param directory a writable directory
* @param appVersion
* @param valueCount the number of values per cache entry. Must be positive.
* @param maxSize the maximum number of bytes this cache should use to store
* @throws java.io.IOException if reading or writing the cache directory fails
*/
public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize)
throws IOException {
if (maxSize <= 0) {
throw new IllegalArgumentException("maxSize <= 0");
}
if (valueCount <= 0) {
throw new IllegalArgumentException("valueCount <= 0");
}
// prefer to pick up where we left off
DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
if (cache.journalFile.exists()) {
try {
cache.readJournal();
cache.processJournal();
cache.journalWriter = new BufferedWriter(new FileWriter(cache.journalFile, true),
IO_BUFFER_SIZE);
return cache;
} catch (IOException journalIsCorrupt) {
// System.logW("DiskLruCache " + directory + " is corrupt: "
// + journalIsCorrupt.getMessage() + ", removing");
cache.delete();
}
}
// create a new empty cache
directory.mkdirs();
cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
cache.rebuildJournal();
return cache;
}
private void readJournal() throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(journalFile), IO_BUFFER_SIZE);
try {
String magic = readAsciiLine(in);
String version = readAsciiLine(in);
String appVersionString = readAsciiLine(in);
String valueCountString = readAsciiLine(in);
String blank = readAsciiLine(in);
if (!MAGIC.equals(magic)
|| !VERSION_1.equals(version)
|| !Integer.toString(appVersion).equals(appVersionString)
|| !Integer.toString(valueCount).equals(valueCountString)
|| !"".equals(blank)) {
throw new IOException("unexpected journal header: ["
+ magic + ", " + version + ", " + valueCountString + ", " + blank + "]");
}
while (true) {
try {
readJournalLine(readAsciiLine(in));
} catch (EOFException endOfJournal) {
break;
}
}
} finally {
closeQuietly(in);
}
}
private void readJournalLine(String line) throws IOException {
String[] parts = line.split(" ");
if (parts.length < 2) {
throw new IOException("unexpected journal line: " + line);
}
String key = parts[1];
if (parts[0].equals(REMOVE) && parts.length == 2) {
lruEntries.remove(key);
return;
}
Entry entry = lruEntries.get(key);
if (entry == null) {
entry = new Entry(key);
lruEntries.put(key, entry);
}
if (parts[0].equals(CLEAN) && parts.length == 2 + valueCount) {
entry.readable = true;
entry.currentEditor = null;
entry.setLengths(copyOfRange(parts, 2, parts.length));
} else if (parts[0].equals(DIRTY) && parts.length == 2) {
entry.currentEditor = new Editor(entry);
} else if (parts[0].equals(READ) && parts.length == 2) {
// this work was already done by calling lruEntries.get()
} else {
throw new IOException("unexpected journal line: " + line);
}
}
/**
* Computes the initial size and collects garbage as a part of opening the
* cache. Dirty entries are assumed to be inconsistent and will be deleted.
*/
private void processJournal() throws IOException {
deleteIfExists(journalFileTmp);
for (Iterator<Entry> i = lruEntries.values().iterator(); i.hasNext(); ) {
Entry entry = i.next();
if (entry.currentEditor == null) {
for (int t = 0; t < valueCount; t++) {
size += entry.lengths[t];
}
} else {
entry.currentEditor = null;
for (int t = 0; t < valueCount; t++) {
deleteIfExists(entry.getCleanFile(t));
deleteIfExists(entry.getDirtyFile(t));
}
i.remove();
}
}
}
/**
* Creates a new journal that omits redundant information. This replaces the
* current journal if it exists.
*/
private synchronized void rebuildJournal() throws IOException {
if (journalWriter != null) {
journalWriter.close();
}
Writer writer = new BufferedWriter(new FileWriter(journalFileTmp), IO_BUFFER_SIZE);
writer.write(MAGIC);
writer.write("\n");
writer.write(VERSION_1);
writer.write("\n");
writer.write(Integer.toString(appVersion));
writer.write("\n");
writer.write(Integer.toString(valueCount));
writer.write("\n");
writer.write("\n");
for (Entry entry : lruEntries.values()) {
if (entry.currentEditor != null) {
writer.write(DIRTY + ' ' + entry.key + '\n');
} else {
writer.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
}
}
writer.close();
journalFileTmp.renameTo(journalFile);
journalWriter = new BufferedWriter(new FileWriter(journalFile, true), IO_BUFFER_SIZE);
}
private static void deleteIfExists(File file) throws IOException {
// try {
// Libcore.os.remove(file.getPath());
// } catch (ErrnoException errnoException) {
// if (errnoException.errno != OsConstants.ENOENT) {
// throw errnoException.rethrowAsIOException();
// }
// }
if (file.exists() && !file.delete()) {
throw new IOException();
}
}
/**
* Returns a snapshot of the entry named {@code key}, or null if it doesn't
* exist is not currently readable. If a value is returned, it is moved to
* the head of the LRU queue.
*/
public synchronized Snapshot get(String key) throws IOException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (entry == null) {
return null;
}
if (!entry.readable) {
return null;
}
/*
* Open all streams eagerly to guarantee that we see a single published
* snapshot. If we opened streams lazily then the streams could come
* from different edits.
*/
InputStream[] ins = new InputStream[valueCount];
try {
for (int i = 0; i < valueCount; i++) {
ins[i] = new FileInputStream(entry.getCleanFile(i));
}
} catch (FileNotFoundException e) {
// a file must have been deleted manually!
return null;
}
redundantOpCount++;
journalWriter.append(READ + ' ' + key + '\n');
if (journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
return new Snapshot(key, entry.sequenceNumber, ins);
}
/**
* Returns an editor for the entry named {@code key}, or null if another
* edit is in progress.
*/
public Editor edit(String key) throws IOException {
return edit(key, ANY_SEQUENCE_NUMBER);
}
private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER
&& (entry == null || entry.sequenceNumber != expectedSequenceNumber)) {
return null; // snapshot is stale
}
if (entry == null) {
entry = new Entry(key);
lruEntries.put(key, entry);
} else if (entry.currentEditor != null) {
return null; // another edit is in progress
}
Editor editor = new Editor(entry);
entry.currentEditor = editor;
// flush the journal before creating files to prevent file leaks
journalWriter.write(DIRTY + ' ' + key + '\n');
journalWriter.flush();
return editor;
}
/**
* Returns the directory where this cache stores its data.
*/
public File getDirectory() {
return directory;
}
/**
* Returns the maximum number of bytes that this cache should use to store
* its data.
*/
public long maxSize() {
return maxSize;
}
/**
* Returns the number of bytes currently being used to store the values in
* this cache. This may be greater than the max size if a background
* deletion is pending.
*/
public synchronized long size() {
return size;
}
private synchronized void completeEdit(Editor editor, boolean success) throws IOException {
Entry entry = editor.entry;
if (entry.currentEditor != editor) {
throw new IllegalStateException();
}
// if this edit is creating the entry for the first time, every index must have a value
if (success && !entry.readable) {
for (int i = 0; i < valueCount; i++) {
if (!entry.getDirtyFile(i).exists()) {
editor.abort();
throw new IllegalStateException("edit didn't create file " + i);
}
}
}
for (int i = 0; i < valueCount; i++) {
File dirty = entry.getDirtyFile(i);
if (success) {
if (dirty.exists()) {
File clean = entry.getCleanFile(i);
dirty.renameTo(clean);
long oldLength = entry.lengths[i];
long newLength = clean.length();
entry.lengths[i] = newLength;
size = size - oldLength + newLength;
}
} else {
deleteIfExists(dirty);
}
}
redundantOpCount++;
entry.currentEditor = null;
if (entry.readable | success) {
entry.readable = true;
journalWriter.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
if (success) {
entry.sequenceNumber = nextSequenceNumber++;
}
} else {
lruEntries.remove(entry.key);
journalWriter.write(REMOVE + ' ' + entry.key + '\n');
}
if (size > maxSize || journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
}
/**
* We only rebuild the journal when it will halve the size of the journal
* and eliminate at least 2000 ops.
*/
private boolean journalRebuildRequired() {
final int REDUNDANT_OP_COMPACT_THRESHOLD = 2000;
return redundantOpCount >= REDUNDANT_OP_COMPACT_THRESHOLD
&& redundantOpCount >= lruEntries.size();
}
/**
* Drops the entry for {@code key} if it exists and can be removed. Entries
* actively being edited cannot be removed.
*
* @return true if an entry was removed.
*/
public synchronized boolean remove(String key) throws IOException {
checkNotClosed();
validateKey(key);
Entry entry = lruEntries.get(key);
if (entry == null || entry.currentEditor != null) {
return false;
}
for (int i = 0; i < valueCount; i++) {
File file = entry.getCleanFile(i);
if (!file.delete()) {
throw new IOException("failed to delete " + file);
}
size -= entry.lengths[i];
entry.lengths[i] = 0;
}
redundantOpCount++;
journalWriter.append(REMOVE + ' ' + key + '\n');
lruEntries.remove(key);
if (journalRebuildRequired()) {
executorService.submit(cleanupCallable);
}
return true;
}
/**
* Returns true if this cache has been closed.
*/
public boolean isClosed() {
return journalWriter == null;
}
private void checkNotClosed() {
if (journalWriter == null) {
throw new IllegalStateException("cache is closed");
}
}
/**
* Force buffered operations to the filesystem.
*/
public synchronized void flush() throws IOException {
checkNotClosed();
trimToSize();
journalWriter.flush();
}
/**
* Closes this cache. Stored values will remain on the filesystem.
*/
public synchronized void close() throws IOException {
if (journalWriter == null) {
return; // already closed
}
for (Entry entry : new ArrayList<Entry>(lruEntries.values())) {
if (entry.currentEditor != null) {
entry.currentEditor.abort();
}
}
trimToSize();
journalWriter.close();
journalWriter = null;
}
private void trimToSize() throws IOException {
while (size > maxSize) {
// Map.Entry<String, Entry> toEvict = lruEntries.eldest();
final Map.Entry<String, Entry> toEvict = lruEntries.entrySet().iterator().next();
remove(toEvict.getKey());
}
}
/**
* Closes the cache and deletes all of its stored values. This will delete
* all files in the cache directory including files that weren't created by
* the cache.
*/
public void delete() throws IOException {
close();
deleteContents(directory);
}
private void validateKey(String key) {
if (key.contains(" ") || key.contains("\n") || key.contains("\r")) {
throw new IllegalArgumentException(
"keys must not contain spaces or newlines: \"" + key + "\"");
}
}
private static String inputStreamToString(InputStream in) throws IOException {
return readFully(new InputStreamReader(in, UTF_8));
}
/**
* A snapshot of the values for an entry.
*/
public final class Snapshot implements Closeable {
private final String key;
private final long sequenceNumber;
private final InputStream[] ins;
private Snapshot(String key, long sequenceNumber, InputStream[] ins) {
this.key = key;
this.sequenceNumber = sequenceNumber;
this.ins = ins;
}
/**
* Returns an editor for this snapshot's entry, or null if either the
* entry has changed since this snapshot was created or if another edit
* is in progress.
*/
public Editor edit() throws IOException {
return DiskLruCache.this.edit(key, sequenceNumber);
}
/**
* Returns the unbuffered stream with the value for {@code index}.
*/
public InputStream getInputStream(int index) {
return ins[index];
}
/**
* Returns the string value for {@code index}.
*/
public String getString(int index) throws IOException {
return inputStreamToString(getInputStream(index));
}
@Override public void close() {
for (InputStream in : ins) {
closeQuietly(in);
}
}
}
/**
* Edits the values for an entry.
*/
public final class Editor {
private final Entry entry;
private boolean hasErrors;
private Editor(Entry entry) {
this.entry = entry;
}
/**
* Returns an unbuffered input stream to read the last committed value,
* or null if no value has been committed.
*/
public InputStream newInputStream(int index) throws IOException {
synchronized (DiskLruCache.this) {
if (entry.currentEditor != this) {
throw new IllegalStateException();
}
if (!entry.readable) {
return null;
}
return new FileInputStream(entry.getCleanFile(index));
}
}
/**
* Returns the last committed value as a string, or null if no value
* has been committed.
*/
public String getString(int index) throws IOException {
InputStream in = newInputStream(index);
return in != null ? inputStreamToString(in) : null;
}
/**
* Returns a new unbuffered output stream to write the value at
* {@code index}. If the underlying output stream encounters errors
* when writing to the filesystem, this edit will be aborted when
* {@link #commit} is called. The returned output stream does not throw
* IOExceptions.
*/
public OutputStream newOutputStream(int index) throws IOException {
synchronized (DiskLruCache.this) {
if (entry.currentEditor != this) {
throw new IllegalStateException();
}
return new FaultHidingOutputStream(new FileOutputStream(entry.getDirtyFile(index)));
}
}
/**
* Sets the value at {@code index} to {@code value}.
*/
public void set(int index, String value) throws IOException {
Writer writer = null;
try {
writer = new OutputStreamWriter(newOutputStream(index), UTF_8);
writer.write(value);
} finally {
closeQuietly(writer);
}
}
/**
* Commits this edit so it is visible to readers. This releases the
* edit lock so another edit may be started on the same key.
*/
public void commit() throws IOException {
if (hasErrors) {
completeEdit(this, false);
remove(entry.key); // the previous entry is stale
} else {
completeEdit(this, true);
}
}
/**
* Aborts this edit. This releases the edit lock so another edit may be
* started on the same key.
*/
public void abort() throws IOException {
completeEdit(this, false);
}
private class FaultHidingOutputStream extends FilterOutputStream {
private FaultHidingOutputStream(OutputStream out) {
super(out);
}
@Override public void write(int oneByte) {
try {
out.write(oneByte);
} catch (IOException e) {
hasErrors = true;
}
}
@Override public void write(byte[] buffer, int offset, int length) {
try {
out.write(buffer, offset, length);
} catch (IOException e) {
hasErrors = true;
}
}
@Override public void close() {
try {
out.close();
} catch (IOException e) {
hasErrors = true;
}
}
@Override public void flush() {
try {
out.flush();
} catch (IOException e) {
hasErrors = true;
}
}
}
}
private final class Entry {
private final String key;
/** Lengths of this entry's files. */
private final long[] lengths;
/** True if this entry has ever been published */
private boolean readable;
/** The ongoing edit or null if this entry is not being edited. */
private Editor currentEditor;
/** The sequence number of the most recently committed edit to this entry. */
private long sequenceNumber;
private Entry(String key) {
this.key = key;
this.lengths = new long[valueCount];
}
public String getLengths() throws IOException {
StringBuilder result = new StringBuilder();
for (long size : lengths) {
result.append(' ').append(size);
}
return result.toString();
}
/**
* Set lengths using decimal numbers like "10123".
*/
private void setLengths(String[] strings) throws IOException {
if (strings.length != valueCount) {
throw invalidLengths(strings);
}
try {
for (int i = 0; i < strings.length; i++) {
lengths[i] = Long.parseLong(strings[i]);
}
} catch (NumberFormatException e) {
throw invalidLengths(strings);
}
}
private IOException invalidLengths(String[] strings) throws IOException {
throw new IOException("unexpected journal line: " + Arrays.toString(strings));
}
public File getCleanFile(int i) {
return new File(directory, key + "." + i);
}
public File getDirtyFile(int i) {
return new File(directory, key + "." + i + ".tmp");
}
}
}
| [
"[email protected]"
] | |
b34c4db4013c3f12ea95b269e247a1a86f455043 | 805ec745004ff5a066393dd81f810f40f1d9e382 | /src/main/java/myFrameU/sms/sdkN/test/MyTest.java | fe238e70a3af14c1eb4431be30932e8e4c18b49f | [] | no_license | ligson/hehuoren | ba9f2bcb36dd7cd97344cc35c462a4f49923c6b6 | 3b98f968e42a633acf9a084a3cc1c47b0aa62181 | refs/heads/master | 2021-01-10T08:44:15.941341 | 2016-01-03T03:05:31 | 2016-01-03T03:05:31 | 48,914,504 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,957 | java | package myFrameU.sms.sdkN.test;
import myFrameU.sms.sdkN.entity.SendResultEntity;
import myFrameU.sms.sdkN.entity.YEEntity;
import myFrameU.sms.sdkN.util.SmsClientOverage;
import myFrameU.sms.sdkN.util.SmsClientSend;
import myFrameU.util.commonUtil.xml.XMLFormat;
public class MyTest {
public static String url = "http://113.11.210.117:8802/sms.aspx";
public static String userid = "45";
public static String account = "njsy";
public static String password = "abcd1234";
public static String checkWord = "这个字符串中是否包含了屏蔽字";
public static void main(String[] args) {
//System.out.println(getYE());
System.out.println(send());
}
//发送短信
public static SendResultEntity send(){
SendResultEntity sre= null;
/**
* <?xml version="1.0" encoding="utf-8" ?><returnsms>
<returnstatus>Success</returnstatus>
<message>ok</message>
<remainpoint>24</remainpoint>
<taskID>490742</taskID>
<successCounts>1</successCounts></returnsms>
*/
String result = SmsClientSend.sendSms(url, userid, account, password, "18754462512", "测试短信内容[艺藏家]");
if(null!=result && !result.equals("")){
sre = (SendResultEntity) XMLFormat.xml2Object(result,SendResultEntity.class );
if(null!=sre){
System.out.println(sre.getMessage()+"===="+sre.getRemainpoint());
}
}
return sre;
}
//查询余额
public static YEEntity getYE(){
YEEntity e = null;
/**
* <?xml version="1.0" encoding="utf-8" ?>
* <returnsms>
<returnstatus>Sucess</returnstatus>
<message></message>
<payinfo>预付费</payinfo>
<overage>25</overage>
<sendTotal>320</sendTotal>
</returnsms>
*/
String result = SmsClientOverage.queryOverage(url, userid, account, password);
if(null!=result){
e = (YEEntity)XMLFormat.xml2Object(result, YEEntity.class);
if(null!=e){
System.out.println(e.getMessage()+"===="+e.getOverage());
}
}
return e;
}
}
| [
"[email protected]"
] | |
ae5c14a0a02680d1c91721cd1569dc68d2d22bb5 | 640597ae80216a683370a6e2663857b12f1c4111 | /ClientTest_1.java | ab81f02c955e9e1bbb548fccca3043e63c4ef5e0 | [] | no_license | MaltheFriisberg/BattleShipGame | 008a28892e68d6c6d6d83f3dc492032b6f0bab72 | ccb2e2c8ad7ccb7a28164631503cadb18e8f0543 | refs/heads/master | 2021-01-10T17:04:13.865480 | 2015-10-05T20:06:56 | 2015-10-05T20:06:56 | 43,710,341 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 684 | java | /*
* Author : Malthe Friisberg : https://github.com/MaltheFriisberg
*/
package BattleShip5;
import BattleShip4.*;
/**
*
* @author Mal
*/
public class ClientTest_1 {
public static void main(String[] args) {
BattleShipClient c = new BattleShipClient(5820, "kurt");
/*GameState p = new GameState();
ObjectFactory f = new ObjectFactory();
p.setTurn(2);
p.setClientLastTurn("Kurt");
byte[] arr = f.GameStatetoBytes(p);
System.out.println(arr.length);
GameState s = f.buildGameState(arr);
System.out.println(s.turn + " "+s.getClientLastTurn()+" "+s.getBytes()); */
}
}
| [
"[email protected]"
] | |
2d3407af99cacf4c6c74743e324c2f18bd2f4df7 | 6e542f91a43ed6a3d20527dd2bfd4d128ef437ea | /src/main/java/com/tusofia/virtuallearningplatform/category/CategoryService.java | 9bfa8b37fe79bcb452ce93e2b465a85637dc28e6 | [] | no_license | IvanSimeonov/virtual-learning-platform-backend-springboot | 5f1e651ec43333e9ae17d1dba6b1444321ef4cf6 | 59ccb1a13fd7fb4e29466cb8fe1b86a765919ea4 | refs/heads/main | 2023-07-09T07:30:10.109556 | 2021-08-23T17:13:26 | 2021-08-23T17:13:26 | 395,595,515 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 659 | java | package com.tusofia.virtuallearningplatform.category;
import com.tusofia.virtuallearningplatform.course.CourseDTO;
import java.util.List;
public interface CategoryService {
long totalCategories();
CategoryDTO createCategory(CategoryDTO categoryDTO);
CategoryDTO findCategoryById(Long id);
List<CategoryDTO> findAllTopLevelCategories();
List<CategoryDTO> findAllMidLevelCategories();
List<CategoryDTO> findAllLowLevelCategories();
List<CategoryDTO> findAllCategories();
List<CourseDTO> findAllCoursesByCategoryId(Long id);
CategoryDTO editCategory(CategoryDTO categoryDTO);
CategoryDTO deleteCategoryById(Long id);
}
| [
"[email protected]"
] | |
5006d0e47c3423fa82c5e64c99d777dbbe648477 | a90feb78de7a429554688abacdb6960e3a7f6223 | /src/main/java/com/yeahmobi/rundemo/guavaexample/collections/utilityclasses/ListsSample.java | fd2d6aa1c4cb458380c50dae7aa8c9e1c382d4c4 | [] | no_license | Corsair007/guavaexample | 086c4d250416879327d6b8a6c8a9ec000753ad13 | 33092391c0aab11bb15b6841b9c49640de93304a | refs/heads/master | 2021-01-01T19:47:07.381451 | 2015-06-02T09:04:58 | 2015-06-02T09:04:58 | 35,934,867 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,192 | java | package com.yeahmobi.rundemo.guavaexample.collections.utilityclasses;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
/**
* @rundemo_name 集合工具类之Lists用法
* @author root
*
*/
public class ListsSample {
public static void main(String[] args) {
//1.一般情况下,我们创建一个List集合
List<String> strList1 = new ArrayList<String>();
strList1.add("1");
strList1.add("2");
strList1.add("3");
//2.使用Collections工具类,可以简化
List<String> strList2 = new ArrayList<String>();
Collections.addAll(strList2, "1", "2", "3");
//3.使用Guava,可以进一步简化:
List<String> strList3 = Lists.newArrayList("1", "2", "3");
System.out.println("strList3: "+ strList3);
//4.List的常用方法
List<Integer> countUp = Ints.asList(1, 2, 3, 4, 5);
System.out.println(countUp);
List<Integer> countDown = Lists.reverse(countUp); // {5, 4, 3, 2, 1}
System.out.println(countDown);
List<List<Integer>> parts = Lists.partition(countUp, 2); // {{1, 2}, {3, 4}, {5}}
System.out.println(parts);
}
}
| [
"[email protected]"
] | |
f97854f5c4752dfee7ebe0cab6bf728fabeca79d | 9a38a072fe281f176fda34f7ef46af7c26101cf2 | /app/src/main/java/com/xiangying/fighting/ui/login/LoginBuz.java | 35cc0205f02a0873440553ebfbea2c8847332948 | [] | no_license | gaoyuan117/Fighting | 91a7c1713ed405f9723f31262b5df9976e0cf29a | 3eabc5b3723738c425e6591e7caee7a614e33c32 | refs/heads/master | 2021-01-22T02:17:51.751170 | 2017-02-09T07:43:42 | 2017-02-09T07:43:42 | 81,041,856 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 218 | java | /*
* LoginPresenter 2016/10/26 15:30
* Copyright (c) 2016 Koterwong All right reserved
*/
package com.xiangying.fighting.ui.login;
/**
* Created by Koterwong on 2016/10/26 15:30
*/
public class LoginBuz {
}
| [
"[email protected]"
] | |
7ab7641b7ef3f79694ede2de8cdd75587c141c2c | 52a35547257212902d8de825b1f3fed7771638ce | /umsDao/src/main/java/com/ums/project/UmsDaoApplication.java | 1564b9bdba2528128ddbdd520bbd13994632758f | [] | no_license | linshupei/project | fbf0976d56ed8f0eb6d53f71f039822174b13039 | 13668bcd18811c967dd983e12bc80d596810ee75 | refs/heads/master | 2021-10-11T20:03:46.656612 | 2019-01-29T09:03:22 | 2019-01-29T09:03:22 | 157,474,700 | 0 | 0 | null | 2018-12-12T05:02:23 | 2018-11-14T01:57:46 | JavaScript | UTF-8 | Java | false | false | 319 | java | package com.ums.project;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class UmsDaoApplication {
public static void main(String[] args) {
SpringApplication.run(UmsDaoApplication.class, args);
}
}
| [
"[email protected]"
] | |
d852bc599e61d614417a81c058e58513e5e3bb82 | 4b00307d7975bcdf166ccdac07bf755435b5ab79 | /jgap_current/examples/src/examples/grid/mathProblemDistributed/MyClientFeedback.java | d1d27ced461e3207cdfa0f108907039bfa122347 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | davidenunes/evolutionary-music | 9fd5ba8fcde390410705fab690311e1e291b545d | 5e8a8c789d43531e3ccb6c2ce46790a6b54f3ad6 | refs/heads/master | 2021-05-27T18:59:09.661679 | 2011-06-08T10:01:16 | 2011-06-08T10:01:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,523 | java | /*
* This file is part of JGAP.
*
* JGAP offers a dual license model containing the LGPL as well as the MPL.
*
* For licensing information please see the file license.txt included with JGAP
* or have a look at the top of class org.jgap.Chromosome which representatively
* includes the JGAP license policy applicable for any file delivered with JGAP.
*/
package examples.grid.mathProblemDistributed;
import org.jgap.*;
import org.jgap.gp.*;
import org.jgap.gp.impl.*;
import org.jgap.distr.grid.gp.*;
import org.jgap.distr.grid.*;
import org.apache.log4j.*;
/**
* Listener for feedback sent to the GP client. This is a simple sample
* implementation.
*
* @author Klaus Meffert
* @since 3.2
*/
public class MyClientFeedback
implements IClientFeedbackGP {
/** String containing the CVS revision. Read out via reflection!*/
private final static String CVS_REVISION = "$Revision: 1.6 $";
private static Logger log = Logger.getLogger(MyClientFeedback.class);
public MyClientFeedback() {
}
public void error(String msg, Exception ex) {
log.error("Error catched on client side: " + msg, ex);
}
public void sendingFragmentRequest(JGAPRequestGP req) {
log.info("Sending work request " + req.getRID());
}
public void receivedFragmentResult(JGAPRequestGP req, JGAPResultGP res,
int idx) {
// This is just a quick and dirty solution.
// Can you do it better?
// ----------------------------------------
GPPopulation pop = res.getPopulation();
if (pop == null || pop.isFirstEmpty()) {
IGPProgram best = res.getFittest();
log.warn("Receiving work (index " + idx + "). Best solution: " +
best.getFitnessValue());
return;
}
if (pop == null) {
log.error("Received empty result/population!");
}
else {
log.warn("Receiving work (index " + idx + "). First solution: " +
pop.getGPProgram(0));
}
}
public void beginWork() {
log.warn("Client starts sending work requests");
}
public void endWork() {
log.warn("Your request was processed completely");
}
public void info(String a_msg) {
log.warn(a_msg);
}
public void setProgressMaximum(int max) {
}
public void setProgressMinimum(int min) {
}
public void setProgressValue(int val) {
}
public void setRenderingTime(JGAPRequest req, long dt) {
}
public void completeFrame(int idx) {
log.warn("Client notified that unit " + idx + " is finished.");
}
}
| [
"[email protected]"
] | |
14bd9ad2229c295c86dd89ad76e2e54e4e4dd038 | 47ee7a20b4671e2869ab3c2a9d1dcfa6135c0c7b | /ComponentImpl/src/main/java/com/cambodia/zhanbang/component/impl/RouterResult.java | 5972fd8de4ae7768cf8df1cf3f9f8bbece28264c | [] | no_license | ganzhex2019/Component | b5e2567d962202f1f2e76cf7a8d2d3055765c8d4 | a754016cb7c1fb38fb383dd1094b3de35c4232c3 | refs/heads/master | 2021-03-17T06:12:59.069407 | 2020-07-15T12:36:03 | 2020-07-15T12:36:03 | 279,779,528 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,420 | java | package com.cambodia.zhanbang.component.impl;
import androidx.annotation.NonNull;
/**
* 这个类表示一次成功路由的返回结果对象
* time : 2018/11/10
*
* @author : xiaojinzi
*/
public class RouterResult {
/**
* 最原始的请求,谁都更改不了的,而且不可能为空在这里
*/
@NonNull
private final RouterRequest mOriginalRequest;
/**
* 如果成功了,这个会有值,这个可能不是最原始的请求啦,可能是拦截器修改过或者
* 整个 request 对象都被改了
*/
@NonNull
private final RouterRequest mFinalRequest;
/**
* @param originalRequest 最原始的请求
* @param finalRequest 可能修改过的请求,也可能是和原始请求一样
*/
public RouterResult(@NonNull RouterRequest originalRequest, @NonNull RouterRequest finalRequest) {
this.mOriginalRequest = originalRequest;
this.mFinalRequest = finalRequest;
}
/**
* 最原始的请求
*
* @return 最原始的请求
*/
@NonNull
public RouterRequest getOriginalRequest() {
return mOriginalRequest;
}
/**
* 获取可能由拦截器修改过的 request 对象,大部分没有被修改的其实就是最原始的 request 对象
*
* @return
*/
@NonNull
public RouterRequest getFinalRequest() {
return mFinalRequest;
}
}
| [
"[email protected]"
] | |
f00a37faf3de41b74fc8981dfd7c0789d6990864 | a28c7bb4151b957de5d885ee0f09482a2d0a5142 | /src/org/edu/Arts.java | 64df9e90862a16a2cfcb1557cdc7ce4da0299dd2 | [] | no_license | sibbenaamulya96/New19march | b382e7bed3d5c5fcf7b4e01e74694f7f5eb0eb86 | 0bbddcf89b5c51fe969d4b163b0e50eba6974998 | refs/heads/master | 2023-03-23T12:53:29.377806 | 2021-03-19T16:09:12 | 2021-03-19T16:09:12 | 349,466,573 | 0 | 0 | null | 2021-03-19T16:09:13 | 2021-03-19T15:18:24 | Java | UTF-8 | Java | false | false | 522 | java | package org.edu;
public class Arts extends Education {
public void bSc() {
System.out.println("bsc");
}
public void bEd() {
System.out.println("bEd");
}
public void bA() {
System.out.println("bA");
}
public void bBA() {
System.out.println("bBA");
}
public void ug() {
System.out.println("ug=22");
}
public void pg() {
System.out.println("pg=12");
}
public static void main(String[] args) {
Arts e=new Arts();
e.bA();
e.bBA();
e.bEd();
e.bSc();
e.pg();
e.ug();
}
}
//amulya new 19th | [
"[email protected]"
] | |
873f9a7a8c1b64e8ade80120598b945bc1df0ef5 | 416010ba4e2a5cef660247e2e8e35aeed1e15273 | /src/main/java/pl/training/domain/Client.java | 19cd0b36e409f45a263f1c7683830a1e1ec44e6a | [] | no_license | wojder/SpringBank | 5e910223f6cb0268e469a491666f91547c637410 | e83e8559c0c7386ac2ace61c3dc674e4133269d0 | refs/heads/master | 2021-01-10T18:49:49.904579 | 2015-01-27T20:39:40 | 2015-01-27T20:39:40 | 29,777,882 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,933 | java | package pl.training.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Client implements Serializable {
private static final long serialVersionUID = 6114327889828540750L;
private Long id;
private String firstName;
private String lastName;
private List<Address> addresses = new ArrayList<>();
private List<Account> accounts = new ArrayList<>();
public Client() {
}
public Client(String firstName, String lastName, Address address) {
this.firstName = firstName;
this.lastName = lastName;
addresses.add(address);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public List<Address> getAddresses() {
return addresses;
}
public void setAddresses(List<Address> addresses) {
this.addresses = addresses;
}
public List<Account> getAccounts() {
return accounts;
}
public void setAccounts(List<Account> accounts) {
this.accounts = accounts;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((addresses == null) ? 0 : addresses.hashCode());
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Client other = (Client) obj;
if (addresses == null) {
if (other.addresses != null) {
return false;
}
} else if (!addresses.equals(other.addresses)) {
return false;
}
if (firstName == null) {
if (other.firstName != null) {
return false;
}
} else if (!firstName.equals(other.firstName)) {
return false;
}
if (lastName == null) {
if (other.lastName != null) {
return false;
}
} else if (!lastName.equals(other.lastName)) {
return false;
}
return true;
}
@Override
public String toString() {
return "Owner [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", addresses=" + addresses
+ "]";
}
}
| [
"[email protected]"
] | |
7bd62a276ffaf0f6d536fac10dd8aa87a4490ae8 | 48a0e5e050c172cd225928a710e3be63398ad6ab | /java-project/src19/main/java/com/eomcs/util/ArrayList.java | 018741a05ca9907ab40cd4773aa0e2bd0da046db | [] | no_license | jeonminhee/bitcamp-java-2018-12 | ce38011132a00580ee7b9a398ce9e47f21b1af8b | a1b5f8befc1c531baf6c238c94a44206b48f8d94 | refs/heads/master | 2020-04-14T04:57:57.565700 | 2019-05-19T06:32:27 | 2019-05-19T06:32:27 | 163,650,679 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,545 | java | package com.eomcs.util;
import java.util.Arrays;
import com.eomcs.lms.domain.Lesson;
public class ArrayList<E> {
static final int DEFAULT_CAPACITY = 10;
Object[] list;
int size = 0;
public ArrayList() {
list = new Object[DEFAULT_CAPACITY];
}
public ArrayList(int initialCapacity) {
if (initialCapacity > DEFAULT_CAPACITY)
list = new Object[initialCapacity];
else
list = new Object[DEFAULT_CAPACITY];
}
@SuppressWarnings("unchecked")
public E[] toArray(E[] a) {
if (a.length < size) {
return (E[]) Arrays.copyOf(list, size, a.getClass());
}
System.arraycopy(list, 0, a, 0, size);
if (a.length > size)
a[size] = null;
return a;
}
public void add(E obj) {
if (size >= list.length) {
int oldCapacity = list.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
list = Arrays.copyOf(list, newCapacity);
}
list[size++] = obj;
}
public int size() {
return this.size;
}
public E get(int index) {
if (index < 0 || index >= size)
return null;
return (E) this.list[index];
}
public E set(int index, E obj) {
if (index < 0 || index >= size)
return null;
E old = (E) list[index];
list[index] = obj;
return old;
}
public E remove(int index) {
if (index < 0 || index >= size)
return null;
E old = (E)list[index];
for (int i = index; i < size -1 ; i++) {
list[i] = list[i + 1];
}
size--;
return old;
}
}
| [
"[email protected]"
] | |
dc372e1e3b19686ee5a8af6d20116d641c4b9c93 | 09d7579c251a72c75448af1994a6104899e5d3ac | /net/src/main/java/com/bcq/net/Processor.java | e689c8410f032823c8faeb8a5f40fa1e3a2def11 | [] | no_license | baichunqiu/oklib | 0d3e38f8c5784f8bb0c4d44d4e8370f61214d856 | cb2094ead9d7e97f0ecc541454a7b17ebf6f6795 | refs/heads/master | 2022-03-13T18:54:02.153995 | 2019-12-03T08:46:51 | 2019-12-03T08:46:51 | 126,003,502 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 271 | java | package com.bcq.net;
import com.oklib.core.ReQuest;
/**
* @author: BaiCQ
* @ClassName: Processor
* @date: 2018/6/27
* @Description: error code processor 错误处理接口
*/
public interface Processor {
void process(int code, ReQuest request);
}
| [
"[email protected]"
] | |
9c6d769e061a511d2329dac4fdb8e15b3b4dfc11 | e7ee311e20b40c87bf6d23a53a1d7b11fd29d2c3 | /applications/mainWebApp/jsp/hd/appmt/HD_APPMT_1206_MDataSet.java | 4e2425e85dd5a5a2ab00e0307930d847c920a2d8 | [] | no_license | nosmoon/misdevteam | 4e3695ef7bbdcd231bb84d7d8d7df54a23ff0a60 | 1829d5bd489eb6dd307ca244f0e183a31a1de773 | refs/heads/master | 2020-04-15T15:57:05.480056 | 2019-01-10T01:12:01 | 2019-01-10T01:12:01 | 164,812,547 | 1 | 0 | null | null | null | null | UHC | Java | false | false | 4,187 | java | /***************************************************************************************************
* 파일명 : .java
* 기능 : 독자우대-구독신청
* 작성일자 : 2007-05-22
* 작성자 : 김대섭
***************************************************************************************************/
/***************************************************************************************************
* 수정내역 :
* 수정자 :
* 수정일자 :
* 백업 :
***************************************************************************************************/
package chosun.ciis.hd.appmt.ds;
import java.sql.*;
import java.util.*;
import somo.framework.db.*;
import somo.framework.util.*;
import chosun.ciis.hd.appmt.dm.*;
import chosun.ciis.hd.appmt.rec.*;
/**
*
*/
public class HD_APPMT_1206_MDataSet extends somo.framework.db.BaseDataSet implements java.io.Serializable{
public String errcode;
public String errmsg;
public String xx_job_clsf_01;
public String xx_cd_clsf_010;
public String xx_mang_cd_5;
public String xx_cd_clsf_020;
public HD_APPMT_1206_MDataSet(){}
public HD_APPMT_1206_MDataSet(String errcode, String errmsg, String xx_job_clsf_01, String xx_cd_clsf_010, String xx_mang_cd_5, String xx_cd_clsf_020){
this.errcode = errcode;
this.errmsg = errmsg;
this.xx_job_clsf_01 = xx_job_clsf_01;
this.xx_cd_clsf_010 = xx_cd_clsf_010;
this.xx_mang_cd_5 = xx_mang_cd_5;
this.xx_cd_clsf_020 = xx_cd_clsf_020;
}
public void setErrcode(String errcode){
this.errcode = errcode;
}
public void setErrmsg(String errmsg){
this.errmsg = errmsg;
}
public void setXx_job_clsf_01(String xx_job_clsf_01){
this.xx_job_clsf_01 = xx_job_clsf_01;
}
public void setXx_cd_clsf_010(String xx_cd_clsf_010){
this.xx_cd_clsf_010 = xx_cd_clsf_010;
}
public void setXx_mang_cd_5(String xx_mang_cd_5){
this.xx_mang_cd_5 = xx_mang_cd_5;
}
public void setXx_cd_clsf_020(String xx_cd_clsf_020){
this.xx_cd_clsf_020 = xx_cd_clsf_020;
}
public String getErrcode(){
return this.errcode;
}
public String getErrmsg(){
return this.errmsg;
}
public String getXx_job_clsf_01(){
return this.xx_job_clsf_01;
}
public String getXx_cd_clsf_010(){
return this.xx_cd_clsf_010;
}
public String getXx_mang_cd_5(){
return this.xx_mang_cd_5;
}
public String getXx_cd_clsf_020(){
return this.xx_cd_clsf_020;
}
public void getValues(CallableStatement cstmt) throws SQLException{
this.errcode = Util.checkString(cstmt.getString(1));
this.errmsg = Util.checkString(cstmt.getString(2));
if(!"".equals(this.errcode)){
return;
}
this.xx_job_clsf_01 = Util.checkString(cstmt.getString(5));
this.xx_cd_clsf_010 = Util.checkString(cstmt.getString(6));
this.xx_mang_cd_5 = Util.checkString(cstmt.getString(7));
this.xx_cd_clsf_020 = Util.checkString(cstmt.getString(8));
}
}/*----------------------------------------------------------------------------------------------------
Web Tier에서 DataSet 객체 관련 코드 작성시 사용하십시오.
<%
HD_APPMT_1206_MDataSet ds = (HD_APPMT_1206_MDataSet)request.getAttribute("ds");
%>
Web Tier에서 Record 객체 관련 코드 작성시 사용하십시오.
----------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------
Web Tier에서 DataSet 객체의 <%= %> 작성시 사용하십시오.
<%= ds.getErrcode()%>
<%= ds.getErrmsg()%>
<%= ds.getXx_job_clsf_01()%>
<%= ds.getXx_cd_clsf_010()%>
<%= ds.getXx_mang_cd_5()%>
<%= ds.getXx_cd_clsf_020()%>
----------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------
Web Tier에서 Record 객체의 <%= %> 작성시 사용하십시오.
----------------------------------------------------------------------------------------------------*/
/* 작성시간 : Thu Jan 26 14:59:45 KST 2012 */ | [
"[email protected]"
] | |
b8e8c0976e05ec159a666f156feba3025b868f8b | 1e3b7fb5e644f0529f1573507a1df45e26d4e155 | /CursoPOOUber/Java/Java/Main.java | 4bcb6e9f1abffd78cb774c84bcdbbba6d843ab1d | [] | no_license | JulyEstrada03/LearningProjects | 81cf538497f9bb6b9b13fb1c1d3fa4b6a0f48f13 | bdb2a7c56713d00a45079df7ad265a6e7e9cec45 | refs/heads/master | 2023-09-02T07:43:11.328198 | 2021-10-21T20:14:23 | 2021-10-21T20:14:23 | 232,424,474 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 457 | java | package Java;
class Main
{
public static void main(String[] args) {
System.out.println("Hola Mundo");
Car car = new Car("ABC123", new Account("July","1545","[email protected]"));
car.printCarInformation();
UberX uberX = new UberX("ABC1234", new Account("July","1545","[email protected]"),"Chevrolet","Aveo");
uberX.serPassenger(4);
uberX.getPassenger();
uberX.printCarInformation();
}
} | [
"[email protected]"
] | |
1d35c3829169ec4fb228b9e39a4288ab5c0d8d05 | 08c5675ad0985859d12386ca3be0b1a84cc80a56 | /src/main/java/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java | cebdcb4ec94808e6d1a9111ae2278660b89732c8 | [] | no_license | ytempest/jdk1.8-analysis | 1e5ff386ed6849ea120f66ca14f1769a9603d5a7 | 73f029efce2b0c5eaf8fe08ee8e70136dcee14f7 | refs/heads/master | 2023-03-18T04:37:52.530208 | 2021-03-09T02:51:16 | 2021-03-09T02:51:16 | 345,863,779 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,800 | java | /*
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.keys.content;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Element;
/**
* @author $Author: coheigea $
* $todo$ implement
*/
public class SPKIData extends SignatureElementProxy implements KeyInfoContent {
/**
* Constructor SPKIData
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public SPKIData(Element element, String BaseURI)
throws XMLSecurityException {
super(element, BaseURI);
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_SPKIDATA;
}
}
| [
"[email protected]"
] | |
8aca78830d99fa1a037d81967183a80cdc7ec7f2 | 3d053fd474be037109afc6ae26fe071cae660961 | /service/src/main/java/service/ComputerService.java | 3c6d563f09d5f495597b2a5f68a356a97a0d34cd | [] | no_license | valenrss/computer-database | 0d293cdce9c83b33d97247767432090fdb4f8fac | 0fbef36b8d47991473412e76faf89c282348ce97 | refs/heads/master | 2020-04-22T03:57:27.411535 | 2019-03-25T16:35:17 | 2019-03-25T16:35:17 | 170,106,707 | 0 | 0 | null | 2019-03-25T16:35:18 | 2019-02-11T10:04:26 | Java | UTF-8 | Java | false | false | 1,652 | java | package service;
import java.util.List;
import org.springframework.stereotype.Service;
import dto.ComputerDTO;
import exception.ComputerNameEmptyException;
import exception.DateOrderException;
import model.Company;
import model.Computer;
/**
* The Interface ComputerService.
*/
@Service
public interface ComputerService {
/**
* Gets all the computers.
*
* @return all computers
*/
public abstract List<ComputerDTO> getAll();
/**
* Adds the computer.
*
* @param cpInsert the cp insert
* @throws ComputerNameEmptyException
* @throws DateOrderException
*/
public abstract void add(Computer cpInsert) throws DateOrderException, ComputerNameEmptyException;
/**
* Update computer.
*
* @param cpInsert the cp insert
* @throws ComputerNameEmptyException
* @throws DateOrderException
*/
public abstract void update(Computer cpInsert) throws DateOrderException, ComputerNameEmptyException;
/**
* Delete computer.
*
* @param id the id
* @return true, if successful
*/
public abstract boolean delete(int id);
/**
* Detail computer.
*
* @param id the id
* @return the computer
*/
public abstract ComputerDTO detail(int id);
/**
* Gets the computers by name.
*
* @param pageNo the page no
* @param objCount the obj count
* @param name the name
* @return researched comptuers
*/
public List<ComputerDTO> getPageByName(int pageNo, int objCount, String name, String orderOption);
/**
* Delete by company.
*
* @param company the company
* @return true, if successful
*/
public boolean deleteByCompany(Company company);
public Long getCount(String name);
}
| [
"[email protected]"
] | |
4e228637ddacd26ed29fae2f5fd5e076e5e3477f | 9f31538e7faf2530ab6779a1410f0ec1db5a37c3 | /testingdockk/src/JToolbarButton.java | fc30349a1785fd5e08bec7e96bbd72e6a14ab111 | [] | no_license | Aishuky11123/NetBeansProjects | 79d48e19e0f511262c359079e48803808a96065f | 306681c8db5333574967f856d5579be1beb19791 | refs/heads/master | 2021-05-28T16:08:58.810329 | 2015-04-04T15:53:40 | 2015-04-04T15:53:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,723 | java | import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* This class represents the buttons used in toolbars.
*
* @author <a href="mailto:[email protected]">Stephane Hillion</a>
* @version $Id: JToolbarButton.java 498555 2007-01-22 08:09:33Z cam $
*/
public class JToolbarButton extends JButton {
/**
* Creates a new toolbar button.
*/
public JToolbarButton() {
initialize();
}
/**
* Creates a new toolbar button.
* @param txt The button text.
*/
public JToolbarButton(String txt) {
super(txt);
initialize();
}
/**
* Initializes the button.
*/
protected void initialize() {
if (!System.getProperty("java.version").startsWith("1.3")) {
setOpaque(false);
setBackground(new java.awt.Color(0, 0, 0, 0));
}
setBorderPainted(false);
setMargin(new Insets(2, 2, 2, 2));
addMouseListener(new MouseListener());
}
/**
* To manage the mouse interactions.
*/
protected class MouseListener extends MouseAdapter {
public void mouseEntered(MouseEvent ev) {
setBorderPainted(true);
}
public void mouseExited(MouseEvent ev) {
setBorderPainted(false);
}
}
public static void main(String re[])
{
JFrame f=new JFrame("adfa");
JToolbarButton b=new JToolbarButton("Click Me");
f.add(b,BorderLayout.CENTER);
f.add(new JPanel(),BorderLayout.NORTH);
f.add(new JPanel(),BorderLayout.SOUTH);
f.add(new JPanel(),BorderLayout.EAST);
f.add(new JPanel(),BorderLayout.WEST);
f.pack();
f.setVisible(true);
}
} | [
"[email protected]"
] | |
beb3d0f4172cb58658528df137e3eb28b326c666 | 670d1d875c6761c1c08b884d62ce2dff000c75e8 | /app/src/main/java/vod/chunyi/com/phonefans/ui/activity/SplashActivity.java | d558c6afa1fe55a1e1f32569ec4725e5dcbd2760 | [] | no_license | HJJKnight/PhoneFans | a54c254146cac67e0c453683d302e62669be4fc5 | dc445d470264b6c9da26bf8948216f99b746cb87 | refs/heads/master | 2021-01-19T01:53:21.378603 | 2017-04-21T08:26:35 | 2017-04-21T08:26:35 | 87,256,223 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,088 | java | package vod.chunyi.com.phonefans.ui.activity;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import vod.chunyi.com.phonefans.R;
import vod.chunyi.com.phonefans.service.DBOperationService;
import vod.chunyi.com.phonefans.ui.activity.base.BaseActivity;
import vod.chunyi.com.phonefans.utils.FileUtils;
import vod.chunyi.com.phonefans.utils.StatusBarUtils;
/**
* Created by knight on 2017/4/11.
*/
public class SplashActivity extends BaseActivity {
private Handler handler = new Handler();
@Override
public int getLayoutId() {
return R.layout.activity_splash;
}
@Override
public void initViews() {
StatusBarUtils.setImage(this);
}
@Override
public void initVaribles(Intent intent) {
// 从 assets 文件夹中复制 db 文件到本地文件夹
copyDB(getResources().getString(R.string.db_name));
// 检验数据库版本 如果不一致进行更换
DBOperationService.CheckDBVersion(getApplicationContext());
handler.postDelayed(new Runnable() {
@Override
public void run() {
HomeActivity.startActivity(SplashActivity.this);
finish();
}
}, 2000);
}
/**
* 从 assets 文件夹里面复制 DB 文件
*
* @param dbName
*/
private void copyDB(String dbName) {
File destFile = new File(getFilesDir(), dbName);
if (!destFile.exists()) {
Log.e("copyDB","copyDB");
try {
InputStream in = getAssets().open(dbName);
FileOutputStream out = new FileOutputStream(destFile);
FileUtils.copyFile(in, out);
} catch (IOException e) {
e.printStackTrace();
}
}
Log.e("copyDB","not_copyDB");
}
@Override
public void onBackPressed() {
super.onBackPressed();
finish();
}
}
| [
"[email protected]"
] | |
dae5d43e41cb28be5db9851b433e2e9fd591d2ec | 58307100c1f882a90dc0641dc2f0da7a9a983a4c | /src/main/java/com/example/entity/User.java | 6ca1edf44877920a76179e08554c7e537b19ab02 | [] | no_license | hepeng1008/SpringBoot-RedisDemo | cc00e39308385479b5a3d14345fa48e13ebbfc89 | 6c788ed35a8fcd591376c3b96d79afa9ebbbaa52 | refs/heads/master | 2021-03-31T01:15:58.924727 | 2018-03-13T01:19:37 | 2018-03-13T01:19:37 | 124,973,009 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 688 | java | package com.example.entity;
import java.io.Serializable;
public class User implements Serializable {
private static final long serialVersionUID=-1L;
private String username;
private Integer age;
public User(String username,Integer age){
this.username=username;
this.age=age;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
| [
"[email protected]"
] | |
ad89fb68b430776e92f4049c606222ee051335fe | 963599f6f1f376ba94cbb504e8b324bcce5de7a3 | /sources/p035ru/unicorn/ujin/view/activity/navigation/p058ui/profile_my_team/TeamProfileFragment.java | 11a14a5b78debf13889a57af41e85770b9d4a2f5 | [] | no_license | NikiHard/cuddly-pancake | 563718cb73fdc4b7b12c6233d9bf44f381dd6759 | 3a5aa80d25d12da08fd621dc3a15fbd536d0b3d4 | refs/heads/main | 2023-04-09T06:58:04.403056 | 2021-04-20T00:45:08 | 2021-04-20T00:45:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,724 | java | package p035ru.unicorn.ujin.view.activity.navigation.p058ui.profile_my_team;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import p035ru.mysmartflat.kortros.R;
import p035ru.unicorn.ujin.data.realm.Resource;
import p035ru.unicorn.ujin.view.activity.navigation.adapter.sectionedadapter.SectionedAdapter;
import p035ru.unicorn.ujin.view.activity.navigation.helper.DialogHelper;
import p035ru.unicorn.ujin.view.activity.navigation.p058ui.base.ViewmodelFactorys;
import p035ru.unicorn.ujin.view.activity.navigation.p058ui.profile_my.MyProfileFragment;
import p035ru.unicorn.ujin.view.activity.navigation.p058ui.profile_my.kotlin.MyProfileViewModel;
import p035ru.unicorn.ujin.view.dialogs.dataEntry.DataEntryDialog;
import p035ru.unicorn.ujin.view.dialogs.dataEntry.EditField;
import p035ru.unicorn.ujin.view.dialogs.dataEntry.Field;
import p035ru.unicorn.ujin.view.fragments.BaseFragment;
import p035ru.unicorn.ujin.view.toolbar.ToolbarButtons;
import p046io.reactivex.functions.Consumer;
/* renamed from: ru.unicorn.ujin.view.activity.navigation.ui.profile_my_team.TeamProfileFragment */
public class TeamProfileFragment extends BaseFragment {
private Button btnAddMember;
private boolean isEditMode;
private MyProfileViewModel myProfileViewModel;
/* renamed from: rv */
private RecyclerView f6853rv;
private SectionedAdapter sectionedAdapter;
private TeamProfileSection teamProfileSection;
/* access modifiers changed from: protected */
public int getLayoutRes() {
return R.layout.fragment_prfile_team;
}
/* access modifiers changed from: protected */
public String metricsScreenName() {
return null;
}
@Nullable
public View onCreateView(LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
setHasOptionsMenu(true);
View inflate = layoutInflater.inflate(getLayoutRes(), viewGroup, false);
this.f6853rv = (RecyclerView) inflate.findViewById(R.id.rv);
this.f6913pb = (ProgressBar) inflate.findViewById(R.id.pb);
this.btnAddMember = (Button) inflate.findViewById(R.id.member);
this.btnAddMember.setOnClickListener(new View.OnClickListener() {
public final void onClick(View view) {
TeamProfileFragment.this.lambda$onCreateView$0$TeamProfileFragment(view);
}
});
initAdapter();
return inflate;
}
public /* synthetic */ void lambda$onCreateView$0$TeamProfileFragment(View view) {
showAddMemberDialog();
}
private void showAddMemberDialog() {
ArrayList arrayList = new ArrayList();
EditField editField = new EditField("phone", getResources().getString(R.string.enterMemberPhone), "", "", (Function2<? super EditText, ? super EditText, Unit>) null, (Function1<? super EditText, Unit>) null);
editField.setName("phone");
editField.setRequired(true);
arrayList.add(editField);
DataEntryDialog newInstance = DataEntryDialog.newInstance((int) R.string.linkAccount, (List<? extends Field>) arrayList, (int) R.string.linkTitle);
newInstance.setLambdaSave(new Function1(newInstance) {
private final /* synthetic */ DataEntryDialog f$1;
{
this.f$1 = r2;
}
public final Object invoke(Object obj) {
return TeamProfileFragment.this.lambda$showAddMemberDialog$1$TeamProfileFragment(this.f$1, (Long) obj);
}
});
newInstance.show(getChildFragmentManager(), "addMember");
}
public /* synthetic */ Unit lambda$showAddMemberDialog$1$TeamProfileFragment(DataEntryDialog dataEntryDialog, Long l) {
return handleSave(dataEntryDialog);
}
private Unit handleSave(DataEntryDialog dataEntryDialog) {
getBaseActivity().hideSoftKeyboard(getBaseActivity());
dataEntryDialog.dismiss();
this.myProfileViewModel.inviteContact(dataEntryDialog.getValuesList()[0]);
this.myProfileViewModel.getTeamInviteContactLiveData().observe(getViewLifecycleOwner(), new Observer() {
public final void onChanged(Object obj) {
TeamProfileFragment.this.addContactToList((Resource) obj);
}
});
return Unit.INSTANCE;
}
private void initAdapter() {
this.sectionedAdapter = new SectionedAdapter();
this.f6853rv.setLayoutManager(new LinearLayoutManager(getActivity()));
this.f6853rv.setAdapter(this.sectionedAdapter);
if (this.teamProfileSection == null) {
this.teamProfileSection = new TeamProfileSection();
this.teamProfileSection.specialClicks().subscribe(new Consumer() {
public final void accept(Object obj) {
TeamProfileFragment.this.onMemberClick((TeamMapper) obj);
}
});
}
this.sectionedAdapter.addSection(this.teamProfileSection);
}
/* access modifiers changed from: private */
public void onMemberClick(TeamMapper teamMapper) {
this.myProfileViewModel.getCurrentChosen().setValue(teamMapper);
nextFragment(MyProfileFragment.start(false, true), false);
}
public void onViewCreated(View view, @Nullable Bundle bundle) {
this.myProfileViewModel = (MyProfileViewModel) ViewModelProviders.m11of((Fragment) this, (ViewModelProvider.Factory) ViewmodelFactorys.getInstance()).get(MyProfileViewModel.class);
this.myProfileViewModel.loadContactList();
this.myProfileViewModel.getTeamContactListLiveData().observe(getViewLifecycleOwner(), new Observer() {
public final void onChanged(Object obj) {
TeamProfileFragment.this.showTeam((Resource) obj);
}
});
}
/* access modifiers changed from: private */
public void showTeam(Resource<List<TeamMapper>> resource) {
this.btnAddMember.setVisibility(0);
if (resource != null) {
int i = C59251.$SwitchMap$ru$unicorn$ujin$data$realm$Resource$Status[resource.getStatus().ordinal()];
if (i == 1) {
this.f6913pb.setVisibility(0);
} else if (i == 2) {
this.teamProfileSection.setData(resource.getData());
this.f6913pb.setVisibility(8);
} else if (i == 3) {
this.f6913pb.setVisibility(8);
DialogHelper.showDialog((Context) getActivity(), resource.getMessage());
}
}
}
/* renamed from: ru.unicorn.ujin.view.activity.navigation.ui.profile_my_team.TeamProfileFragment$1 */
static /* synthetic */ class C59251 {
static final /* synthetic */ int[] $SwitchMap$ru$unicorn$ujin$data$realm$Resource$Status = new int[Resource.Status.values().length];
/* JADX WARNING: Can't wrap try/catch for region: R(8:0|1|2|3|4|5|6|8) */
/* JADX WARNING: Failed to process nested try/catch */
/* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
/* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001f */
static {
/*
ru.unicorn.ujin.data.realm.Resource$Status[] r0 = p035ru.unicorn.ujin.data.realm.Resource.Status.values()
int r0 = r0.length
int[] r0 = new int[r0]
$SwitchMap$ru$unicorn$ujin$data$realm$Resource$Status = r0
int[] r0 = $SwitchMap$ru$unicorn$ujin$data$realm$Resource$Status // Catch:{ NoSuchFieldError -> 0x0014 }
ru.unicorn.ujin.data.realm.Resource$Status r1 = p035ru.unicorn.ujin.data.realm.Resource.Status.LOADING // Catch:{ NoSuchFieldError -> 0x0014 }
int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x0014 }
r2 = 1
r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x0014 }
L_0x0014:
int[] r0 = $SwitchMap$ru$unicorn$ujin$data$realm$Resource$Status // Catch:{ NoSuchFieldError -> 0x001f }
ru.unicorn.ujin.data.realm.Resource$Status r1 = p035ru.unicorn.ujin.data.realm.Resource.Status.SUCCESS // Catch:{ NoSuchFieldError -> 0x001f }
int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x001f }
r2 = 2
r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x001f }
L_0x001f:
int[] r0 = $SwitchMap$ru$unicorn$ujin$data$realm$Resource$Status // Catch:{ NoSuchFieldError -> 0x002a }
ru.unicorn.ujin.data.realm.Resource$Status r1 = p035ru.unicorn.ujin.data.realm.Resource.Status.ERROR // Catch:{ NoSuchFieldError -> 0x002a }
int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x002a }
r2 = 3
r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x002a }
L_0x002a:
return
*/
throw new UnsupportedOperationException("Method not decompiled: p035ru.unicorn.ujin.view.activity.navigation.p058ui.profile_my_team.TeamProfileFragment.C59251.<clinit>():void");
}
}
/* access modifiers changed from: private */
public void addContactToList(Resource<TeamMapper> resource) {
if (resource != null) {
int i = C59251.$SwitchMap$ru$unicorn$ujin$data$realm$Resource$Status[resource.getStatus().ordinal()];
if (i == 1) {
this.f6913pb.setVisibility(0);
} else if (i == 2) {
this.f6913pb.setVisibility(8);
showMessage(getResources().getString(R.string.linkAccountSuccess));
} else if (i == 3) {
this.f6913pb.setVisibility(8);
DialogHelper.showDialog((Context) getActivity(), resource.getMessage());
}
}
}
/* access modifiers changed from: protected */
public void showToolbar() {
getBaseActivity().setToolbarLeft(ToolbarButtons.BACK);
getBaseActivity().setTextTitle(getString(R.string.title_team));
}
}
| [
"[email protected]"
] | |
583d85a9dec03601417e7f5dc41916c9d41ba2cd | 73b98168884a436604e7f25ca42c722df1f4d7d3 | /common/src/testFixtures/java/com/vivier_technologies/common/admin/TestAdminReceiver.java | dcd273432b4e2ce8bd35fe0ba85e7c9d2c5f60ee | [
"Apache-2.0"
] | permissive | vivier-technologies/sequencer | 996ed75f9065c3a7a31ac128519fc79898214cc5 | 2978f4b498ee8edd9c90fcc4dd7febaf2a5a52a0 | refs/heads/master | 2022-08-03T17:51:43.091783 | 2020-05-27T21:18:53 | 2020-05-27T21:18:53 | 249,950,813 | 1 | 0 | Apache-2.0 | 2020-05-27T21:18:54 | 2020-03-25T10:39:00 | Java | UTF-8 | Java | false | false | 931 | java | /*
* Copyright 2020 vivier technologies
*
* 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.vivier_technologies.common.admin;
import java.io.IOException;
public class TestAdminReceiver implements AdminReceiver {
@Override
public void open() throws IOException {
}
@Override
public void close() {
}
@Override
public void setHandler(AdminHandler handler) {
}
}
| [
"[email protected]"
] | |
12cd7b8515a8c72bbe67e6de8e2ba6cd4e232433 | 0fe3a5cdbaa6ca43e9ce5561343f2f95ea6b785a | /inavigator-core/source/inav-core/src/main/java/ru/sberbank/syncserver2/service/datamappers/DatapowerResultObjectListHandler.java | 25fa26ad9b5e0fac81860ea608ca3bd779be5d0a | [] | no_license | 552847957/inavigator-server | d25cd890d639bde885d7eaf3cda7f20699d3e237 | ca682e9894fcaa90b86e65eab291abceda6d9c1f | refs/heads/master | 2020-11-23T21:09:59.503923 | 2019-11-08T17:00:01 | 2019-11-08T17:00:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 236 | java | package ru.sberbank.syncserver2.service.datamappers;
import java.io.IOException;
import java.util.List;
public interface DatapowerResultObjectListHandler<T> {
public void handleResultObjectList(List<T> results) throws IOException;
}
| [
"[email protected]"
] | |
69369b0201b708c6ae327ac19eb838afb92a2014 | e8ca0a7674819bc657037fa08e749dd24be2d289 | /src/main/java/spring/jasper/domain/Document.java | 98dc83f1e2a97ba59aadd64b4b4508701ae80c0e | [] | no_license | eliasvargasloyola/initial-spring-jasper | 4276fca14aab60ae13babb8eef747b3840f060d3 | 7d7d15067c4763807bbba30da006fe25f12c6da3 | refs/heads/master | 2022-03-27T17:33:26.385624 | 2019-12-10T17:46:25 | 2019-12-10T17:46:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,000 | java | package spring.jasper.domain;
import java.io.Serializable;
public class Document implements Serializable {
private String amount;
private String caseDoc;
private String document;
private String bol;
public Document(String amount, String caseDoc, String document, String bol) {
this.amount = amount;
this.caseDoc = caseDoc;
this.document = document;
this.bol = bol;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getCaseDoc() {
return caseDoc;
}
public void setCaseDoc(String caseDoc) {
this.caseDoc = caseDoc;
}
public String getDocument() {
return document;
}
public void setDocument(String document) {
this.document = document;
}
public String getBol() {
return bol;
}
public void setBol(String bol) {
this.bol = bol;
}
}
| [
"[email protected]"
] | |
c381c269e195397b0f46cbe616a1fd1af8220ee0 | 5112b1d7720a6b72aaa6763f2d3616f6abb37236 | /common-component/v3.7.3/src/main/java/egovframework/com/uss/ion/bnt/service/impl/BndtManageDAO.java | 117c31f0211446c5031493b20e275ce8e5751f85 | [] | no_license | dasomel/egovframework | 1c5435f7b5ce6834379ec7f66cc546db18862b0b | a2fcdbf0a0a98e5a2ab8a3193f33cab9f1cd26e7 | refs/heads/master | 2021-06-03T10:44:26.848513 | 2020-11-03T07:27:05 | 2020-11-03T07:27:05 | 24,672,345 | 3 | 3 | null | null | null | null | UTF-8 | Java | false | false | 7,473 | java | package egovframework.com.uss.ion.bnt.service.impl;
import java.util.List;
import egovframework.com.cmm.service.impl.EgovComAbstractDAO;
import egovframework.com.uss.ion.bnt.service.BndtCeckManage;
import egovframework.com.uss.ion.bnt.service.BndtCeckManageVO;
import egovframework.com.uss.ion.bnt.service.BndtDiary;
import egovframework.com.uss.ion.bnt.service.BndtDiaryVO;
import egovframework.com.uss.ion.bnt.service.BndtManage;
import egovframework.com.uss.ion.bnt.service.BndtManageVO;
import org.springframework.stereotype.Repository;
/**
* 개요
* - 당직관리에 대한 DAO 클래스를 정의한다.
*
* 상세내용
* - 당직관리에 대한 등록, 수정, 삭제, 조회, 반영확인 기능을 제공한다.
* - 당직관리의 조회기능은 목록조회, 상세조회로 구분된다.
* @author 이용
* @version 1.0
* @created 06-15-2010 오후 2:08:56
*/
@Repository("bndtManageDAO")
public class BndtManageDAO extends EgovComAbstractDAO {
/**
* 당직관리정보를 관리하기 위해 등록된 당직관리 목록을 조회한다.
* @param bndtManageVO - 당직관리 VO
* @return List - 당직관리 목록
*/
@SuppressWarnings("unchecked")
public List<BndtManageVO> selectBndtManageList(BndtManageVO bndtManageVO) throws Exception {
return (List<BndtManageVO>) list("bndtManageDAO.selectBndtManageList", bndtManageVO);
}
/**
* 당직관리목록 총 갯수를 조회한다.
* @param bndtManageVO - 당직관리 VO
* @return int
* @exception Exception
*/
public int selectBndtManageListTotCnt(BndtManageVO bndtManageVO) throws Exception {
return (Integer)select("bndtManageDAO.selectBndtManageListTotCnt", bndtManageVO);
}
/**
* 등록된 당직관리의 상세정보를 조회한다.
* @param bndtManageVO - 당직관리 VO
* @return BndtManageVO - 당직관리 VO
*/
public BndtManageVO selectBndtManage(BndtManageVO bndtManageVO) throws Exception {
return (BndtManageVO) select("bndtManageDAO.selectBndtManage", bndtManageVO);
}
/**
* 당직관리정보를 신규로 등록한다.
* @param bndtManage - 당직관리 model
*/
public void insertBndtManage(BndtManage bndtManage) throws Exception {
insert("bndtManageDAO.insertBndtManage", bndtManage);
}
/**
* 기 등록된 당직관리정보를 수정한다.
* @param bndtManage - 당직관리 model
*/
public void updtBndtManage(BndtManage bndtManage) throws Exception {
update("bndtManageDAO.updtBndtManage", bndtManage);
}
/**
* 기 등록된 당직관리정보를 삭제한다.
* @param bndtManage - 당직관리 model
*/
public void deleteBndtManage(BndtManage bndtManage) throws Exception {
delete("bndtManageDAO.deleteBndtManage",bndtManage);
}
/**
* 당직일지 갯수를 조회한다.
* @param bndtManageVO - 당직관리 VO
* @return int
* @exception Exception
*/
public int selectBndtDiaryTotCnt(BndtManage bndtManage) throws Exception {
return (Integer)select("bndtManageDAO.selectBndtDiaryTotCnt", bndtManage);
}
/***** 당직 체크관리 *****/
/**
* 당직체크관리정보를 관리하기 위해 등록된 당직체크관리 목록을 조회한다.
* @param bndtCeckManageVO - 당직체크관리 VO
* @return List - 당직체크관리 목록
*/
@SuppressWarnings("unchecked")
public List<BndtCeckManageVO> selectBndtCeckManageList(BndtCeckManageVO bndtCeckManageVO) throws Exception {
return (List<BndtCeckManageVO>) list("bndtManageDAO.selectBndtCeckManageList", bndtCeckManageVO);
}
/**
* 당직체크관리목록 총 갯수를 조회한다.
* @param bndtCeckManageVO - 당직체크관리 VO
* @return int
* @exception Exception
*/
public int selectBndtCeckManageListTotCnt(BndtCeckManageVO bndtCeckManageVO) throws Exception {
return (Integer)select("bndtManageDAO.selectBndtCeckManageListTotCnt", bndtCeckManageVO);
}
/**
* 등록된 당직체크관리의 상세정보를 조회한다.
* @param bndtCeckManageVO - 당직체크관리 VO
* @return BndtCeckManageVO - 당직체크관리 VO
*/
public BndtCeckManageVO selectBndtCeckManage(BndtCeckManageVO bndtCeckManageVO) throws Exception {
return (BndtCeckManageVO) select("bndtManageDAO.selectBndtCeckManage", bndtCeckManageVO);
}
/**
* 당직체크관리정보를 신규로 등록한다.
* @param bndtCeckManage - 당직체크관리 model
*/
public void insertBndtCeckManage(BndtCeckManage bndtCeckManage) throws Exception {
insert("bndtManageDAO.insertBndtCeckManage", bndtCeckManage);
}
/**
* 기 등록된 당직체크관리정보를 수정한다.
* @param bndtCeckManage - 당직체크관리 model
*/
public void updtBndtCeckManage(BndtCeckManage bndtCeckManage) throws Exception {
update("bndtManageDAO.updtBndtCeckManage", bndtCeckManage);
}
/**
* 기 등록된 당직체크관리정보를 삭제한다.
* @param bndtCeckManage - 당직체크관리 model
*/
public void deleteBndtCeckManage(BndtCeckManage bndtCeckManage) throws Exception {
delete("bndtManageDAO.deleteBndtCeckManage",bndtCeckManage);
}
/**
* 당직체크 중복여부 조회한다.
* @param bndtCeckManageVO - 당직체크관리 VO
* @return int
* @exception Exception
*/
public int selectBndtCeckManageDplctAt(BndtCeckManage bndtCeckManage) throws Exception {
return (Integer)select("bndtManageDAO.selectBndtCeckManageDplctAt", bndtCeckManage);
}
/***** 당직 일지 *****/
/**
* 등록된 당직일지관리의 상세정보를 조회한다.
* @param bndtDiaryVO - 당직일지관리 VO
* @return List - 당직일지관리 VO
*/
@SuppressWarnings("unchecked")
public List<BndtDiaryVO> selectBndtDiary(BndtDiaryVO bndtDiaryVO) throws Exception {
return (List<BndtDiaryVO>) list("bndtManageDAO.selectBndtDiary", bndtDiaryVO);
}
/**
* 당직일지관리정보를 신규로 등록한다.
* @param bndtDiary - 당직일지관리 model
*/
public void insertBndtDiary(BndtDiary bndtDiary) throws Exception {
insert("bndtManageDAO.insertBndtDiary", bndtDiary);
}
/**
* 기 등록된 당직일지관리정보를 수정한다.
* @param bndtDiary - 당직일지관리 model
*/
public void updtBndtDiary(BndtDiary bndtDiary) throws Exception {
update("bndtManageDAO.updtBndtDiary", bndtDiary);
}
/**
* 기 등록된 당직일지관리정보를 삭제한다.
* @param bndtDiary - 당직일지관리 model
*/
public void deleteBndtDiary(BndtDiary bndtDiary) throws Exception {
delete("bndtManageDAO.deleteBndtDiary",bndtDiary);
}
/**
* 등록된 당직관리의 상세정보를 조회한다.
* @param bndtManageVO - 당직관리 VO
* @return BndtManageVO - 당직관리 VO
*/
public BndtManageVO selectBndtManageBnde(BndtManageVO bndtManageVO) throws Exception {
return (BndtManageVO) select("bndtManageDAO.selectBndtManageBnde", bndtManageVO);
}
/**
* 당직관리 등록건수 조회한다.
* @param bndtManageVO - 당직관리 VO
* @return int
* @exception Exception
*/
public int selectBndtManageMonthCnt(BndtManageVO bndtManageVO) throws Exception {
return (Integer)select("bndtManageDAO.selectBndtManageMonthCnt", bndtManageVO);
}
}
| [
"[email protected]"
] | |
cbb4832edbe52abda784afe1cc7fb7da4d0f1083 | cdd2edeb338e03a289b96fc8b66e0f4f1f4026ba | /chapter14/src/com/zy/rtti/ResisteredFactories.java | 804f00d0c0162c7d7276626e96744e1f780f63b7 | [] | no_license | myclass242/thinking-in-java | 56955f4f3d068c01c851645902a14fd5b9dd416b | cfa5f96660f8bdabd8a55653e0b4fa885b4bbecd | refs/heads/master | 2020-04-10T03:51:29.074842 | 2019-03-02T15:13:16 | 2019-03-02T15:13:16 | 160,781,483 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,329 | java | package com.zy.rtti;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
interface Factory<T> {T create();}
class Part {
public String toString() {
return getClass().getSimpleName();
}
static List<Factory<? extends Part>> partFactories =
new ArrayList<Factory<? extends Part>>();
static {
partFactories.add(new FuelFilter.Factory());
partFactories.add(new AirFilter.Factory());
partFactories.add(new CabinAirFilter.Factory());
partFactories.add(new OilFilter.Factory());
partFactories.add(new GeneratorBelt.Factory());
partFactories.add(new PowerSteeringBelt.Factory());
}
private static Random rand = new Random(47);
public static Part createRandom() {
int n = rand.nextInt(partFactories.size());
return partFactories.get(n).create();
}
}
class Filter extends Part {}
class FuelFilter extends Filter {
public static class Factory
implements com.zy.rtti.Factory<FuelFilter> {
public FuelFilter create() {return new FuelFilter();}
}
}
class AirFilter extends Filter {
public static class Factory
implements com.zy.rtti.Factory<AirFilter> {
public AirFilter create() {return new AirFilter();}
}
}
class CabinAirFilter extends Filter {
public static class Factory
implements com.zy.rtti.Factory<CabinAirFilter> {
public CabinAirFilter create() {return new CabinAirFilter();}
}
}
class OilFilter extends Filter {
public static class Factory
implements com.zy.rtti.Factory<OilFilter> {
public OilFilter create() {return new OilFilter();}
}
}
class Belt extends Part {};
class GeneratorBelt extends Belt {
public static class Factory
implements com.zy.rtti.Factory<GeneratorBelt> {
public GeneratorBelt create() {return new GeneratorBelt();}
}
}
class PowerSteeringBelt extends Belt {
public static class Factory
implements com.zy.rtti.Factory<PowerSteeringBelt> {
public PowerSteeringBelt create() {return new PowerSteeringBelt();}
}
}
public class ResisteredFactories {
public static void main(String[] args) {
for (int i = 0; i < 10; ++i) {
System.out.println(Part.createRandom());
}
}
}
| [
"[email protected]"
] | |
ad52ec6f58a81bfff84078de9d6312fde173322e | 21c8fc01a85a48cafbbd23bfb1878d8a561dd6ab | /LectureB4/src/week8Abstract/RemoteWebdriverTest.java | 5ea3c5843e9b5da891b4c998d82d29898f6ac8d0 | [] | no_license | ahmetcturk/javaCodes | b9386c1391e16e222ba91673ec153324992837e5 | 9aec1622000a930681f41753c2ce11d4480b9ce3 | refs/heads/master | 2021-05-18T02:29:38.499551 | 2020-12-17T15:03:16 | 2020-12-17T15:03:16 | 251,065,533 | 14 | 11 | null | null | null | null | UTF-8 | Java | false | false | 314 | java | package week8Abstract;
public class RemoteWebdriverTest {
public static void main(String[] args) {
RemoteWebDriver driver = new FireFoxDriver();
driver.get("https://www.google.com");
driver.quit();
driver = new ChromeDriver();
driver.get("https://www.siliconelabs.com");
driver.quit();
}
}
| [
"[email protected]"
] | |
b096e633303189cfc8e7bd1e5fa31982a7ff4bdd | c41b48775fc11ca43e7c02549e0515ba87f7a812 | /src/main/java/Day7techniquesToautomateWebElements/DropDownLoopingUI.java | 85db974ffc068bf8dcada069d023db5136768326 | [] | no_license | panache-chinmay/Selenium | 1611860bd0e5bd3cf2540f20a790a43b15ec8308 | d11607ac207aac98640c5dd944c23a4cbe789dbe | refs/heads/master | 2022-07-06T07:25:20.325179 | 2019-06-26T09:47:42 | 2019-06-26T09:47:42 | 188,793,931 | 0 | 1 | null | 2022-06-29T17:24:01 | 2019-05-27T07:32:22 | HTML | UTF-8 | Java | false | false | 1,155 | java | package Day7techniquesToautomateWebElements;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
public class DropDownLoopingUI {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver ;
System.setProperty("webdriver.chrome.driver","C:\\Users\\chinmay.deshpande.ZA\\Desktop\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.spicejet.com");
driver.findElement(By.id("divpaxinfo")).click();
Thread.sleep(2000L);
// With while loop
/*int i=1;
while(i<5)
{
driver.findElement(By.id("hrefIncAdt")).click();//4 times
i++;
}*/
// With for loop
System.out.println(driver.findElement(By.id("divpaxinfo")).getText());
for(int i=1;i<5;i++)
{
driver.findElement(By.id("hrefIncAdt")).click();
}
driver.findElement(By.id("btnclosepaxoption")).click();
Assert.assertEquals(driver.findElement(By.id("divpaxinfo")).getText(), "5 Adult");
System.out.println(driver.findElement(By.id("divpaxinfo")).getText());
}
}
| [
"[email protected]"
] | |
29880eb560b7a6f1ff4bacbc1380c765cf78dfc0 | fd7f0b9b8af4645fa6aa3097d565f6bb0eda9e40 | /src/io/keen/client/android/exceptions/InvalidEventException.java | 0ac84e3d72681cf78e76b5947db2a149591c4215 | [
"MIT"
] | permissive | BenV/KeenClient-Android | 0e3b6c1440c38afd65de5cdaa8d0b6054c1dc1a8 | b851dce30f86bec3ccf7a0dafb260489090fbcc1 | refs/heads/master | 2020-04-05T18:59:24.530389 | 2014-09-05T01:03:35 | 2014-09-05T01:03:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 268 | java | package io.keen.client.android.exceptions;
/**
* InvalidEventException
*
* @author dkador
* @since 1.0.0
*/
public class InvalidEventException extends KeenException {
public InvalidEventException(String detailMessage) {
super(detailMessage);
}
}
| [
"[email protected]"
] | |
0efc69df5373e0aeced6974d5fe37343dff9aabe | c5ac5f0ff2e0e1bbf51f2eb38972f207e0bb5d12 | /test_tasks/src/main/java/ru/job4j/siteparser/utils/PropertiesManager.java | 49aed502c078ebf568aebfd84baf05e8112c2e62 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Rodriguez111/job4j | fae14cb95ad2b2f5fe70b33ca7acf3c339036555 | 85237b8b9b77895b42fd62fd1555cc175a791af3 | refs/heads/master | 2022-12-22T19:41:12.022558 | 2020-01-02T05:57:57 | 2020-01-02T05:57:57 | 156,921,927 | 0 | 0 | Apache-2.0 | 2022-12-16T14:51:21 | 2018-11-09T21:50:15 | Java | UTF-8 | Java | false | false | 1,183 | java | package ru.job4j.siteparser.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropertiesManager {
private static File propertiesFile = null;
public static void setPropertiesFile(File propertiesFile) {
PropertiesManager.propertiesFile = propertiesFile;
}
private static Properties getProperties() {
Properties properties = new Properties();
try (InputStream inputStream = new FileInputStream(propertiesFile)) {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
return properties;
}
public static String getSqlDriver() {
return getProperties().getProperty("jdbc.driver");
}
public static String getDbUrl() {
return getProperties().getProperty("jdbc.url");
}
public static String getDbDirPath() {
File file = new File(getProperties().getProperty("jdbc.dbpath"));
return file.getParent();
}
public static String getTime() {
return getProperties().getProperty("cron.time");
}
}
| [
"[email protected]"
] | |
c54b87791b24a2d3605836ba947cec984a049a7b | 776031c494e397f39c055bcf56bc266d078a4ba4 | /common/src/main/java/org/geogebra/common/geogebra3D/input3D/EuclidianViewInput3DCompanion.java | 881e6494181cec5d2715bca743d6daf49a48dc77 | [] | no_license | geogebra/geogebra | 85f648e733454c5b471bf7b13b54607979bb1830 | 210ee8862951f91cecfb3a76a9c4114019c883b8 | refs/heads/master | 2023-09-05T11:09:42.662430 | 2023-09-05T08:10:05 | 2023-09-05T08:10:05 | 2,543,687 | 1,319 | 389 | null | 2023-07-20T11:49:58 | 2011-10-09T17:57:35 | Java | UTF-8 | Java | false | false | 23,984 | java | package org.geogebra.common.geogebra3D.input3D;
import org.geogebra.common.awt.GColor;
import org.geogebra.common.awt.GPoint;
import org.geogebra.common.awt.GPointWithZ;
import org.geogebra.common.euclidian.EuclidianConstants;
import org.geogebra.common.euclidian.EuclidianController;
import org.geogebra.common.euclidian.EuclidianCursor;
import org.geogebra.common.euclidian.EuclidianView;
import org.geogebra.common.euclidian.Hits;
import org.geogebra.common.euclidian.event.PointerEventType;
import org.geogebra.common.geogebra3D.euclidian3D.EuclidianView3D;
import org.geogebra.common.geogebra3D.euclidian3D.EuclidianView3DCompanion;
import org.geogebra.common.geogebra3D.euclidian3D.draw.DrawSegment3D;
import org.geogebra.common.geogebra3D.euclidian3D.openGL.PlotterCompletingCursor;
import org.geogebra.common.geogebra3D.euclidian3D.openGL.PlotterCursor;
import org.geogebra.common.geogebra3D.euclidian3D.openGL.Renderer;
import org.geogebra.common.geogebra3D.input3D.Input3D.OutOfField;
import org.geogebra.common.geogebra3D.kernel3D.geos.GeoPlane3DConstant;
import org.geogebra.common.geogebra3D.kernel3D.geos.GeoPoint3D;
import org.geogebra.common.geogebra3D.kernel3D.geos.GeoSegment3D;
import org.geogebra.common.kernel.ModeSetter;
import org.geogebra.common.kernel.geos.GeoElement;
import org.geogebra.common.kernel.kernelND.GeoPointND;
import org.geogebra.common.kernel.matrix.CoordMatrix4x4;
import org.geogebra.common.kernel.matrix.Coords;
/**
* Companion for EuclidianView3D using Input3D
*
*/
public class EuclidianViewInput3DCompanion extends EuclidianView3DCompanion {
private Input3D input3D;
private Coords completingCursorOrigin;
private Coords mouse3DScreenPosition = null;
private Coords mouse3DScenePosition;
protected CoordMatrix4x4 tmpMatrix4x4_3 = CoordMatrix4x4.identity();
private GeoSegment3D stylusBeam;
private DrawSegment3D stylusBeamDrawable;
boolean stylusBeamIsVisible;
static private int STYLUS_BEAM_THICKNESS = 9;
private HittedGeo hittedGeo = new HittedGeo();
private StationaryCoords stationaryCoords = new StationaryCoords();
private Coords tmpCoords1 = new Coords(4);
final static protected float LONG_DELAY = 1500f;
final private static double GRAY_SCALE_FOR_INPUT3D = 255 * 0.75;
/**
* @param view
* 3D view
*/
public EuclidianViewInput3DCompanion(EuclidianView view) {
super(view);
mouse3DScenePosition = new Coords(4);
mouse3DScenePosition.setW(1);
}
/**
* @param input3D
* 3D input
*/
public void setInput3D(Input3D input3D) {
this.input3D = input3D;
if (input3D.useCompletingDelay()) {
completingCursorOrigin = Coords.createInhomCoorsInD3();
}
}
@Override
public void drawMouseCursor(Renderer renderer1) {
if (input3D.currentlyUseMouse2D()) {
super.drawMouseCursor(renderer1);
return;
}
if (input3D.hasMouseDirection()) {
return;
}
// use a 3D mouse position
mouse3DScreenPosition = input3D.getMouse3DPosition();
if (input3D.useCompletingDelay()) {
if (drawCompletingCursor(renderer1)) {
return;
}
// draw mouse cursor at the same place
renderer1.drawMouseCursor();
return;
}
getView().drawMouseCursor(renderer1, mouse3DScreenPosition);
}
/**
* @param renderer1
* renderer
* @return false if we need also the mouse cursor
*/
private boolean drawCompletingCursor(Renderer renderer1) {
// are we grabbing?
float hittedGeoCompletingDelay = hittedGeo.getCompletingDelay();
if (hittedGeoCompletingDelay > PlotterCompletingCursor.START_DRAW
&& hittedGeoCompletingDelay <= PlotterCompletingCursor.END_DRAW) {
CoordMatrix4x4.identity(tmpMatrix4x4_3);
completingCursorOrigin
.setValues(getView().getCursor3D().getInhomCoordsInD3(), 3);
getView().toScreenCoords3D(completingCursorOrigin);
return drawCompletingCursor(renderer1, completingCursorOrigin,
hittedGeoCompletingDelay);
}
// are we releasing?
float stationaryCoordsCompletingDelay = stationaryCoords
.getCompletingDelay();
if (stationaryCoordsCompletingDelay > PlotterCompletingCursor.START_DRAW
&& stationaryCoordsCompletingDelay <= PlotterCompletingCursor.END_DRAW) {
CoordMatrix4x4.identity(tmpMatrix4x4_3);
completingCursorOrigin
.setValues(stationaryCoords.getCurrentCoords(), 3);
getView().toScreenCoords3D(completingCursorOrigin);
drawCompletingCursor(renderer1, completingCursorOrigin,
1 - stationaryCoordsCompletingDelay);
return true;
}
// are we moving?
if (stationaryCoordsCompletingDelay >= 0
&& stationaryCoordsCompletingDelay <= PlotterCompletingCursor.START_DRAW) {
CoordMatrix4x4.identity(tmpMatrix4x4_3);
completingCursorOrigin
.setValues(stationaryCoords.getCurrentCoords(), 3);
getView().toScreenCoords3D(completingCursorOrigin);
drawCompletingCursor(renderer1, completingCursorOrigin, 1);
return true;
}
// are we over a moveable geo?
if (hittedGeo.getGeo() != null
&& hittedGeoCompletingDelay <= PlotterCompletingCursor.START_DRAW) {
CoordMatrix4x4.identity(tmpMatrix4x4_3);
completingCursorOrigin
.setValues(getView().getCursor3D().getInhomCoordsInD3(), 3);
getView().toScreenCoords3D(completingCursorOrigin);
return drawCompletingCursor(renderer1, completingCursorOrigin, 0);
}
// nothing hitted
completingCursorOrigin.setValues(mouse3DScreenPosition, 3);
return drawCompletingCursor(renderer1, completingCursorOrigin, 0);
}
/**
* @return false if we need also the mouse cursor
*/
private boolean drawCompletingCursor(Renderer renderer1, Coords origin,
float completingDelay) {
switch (input3D.getOutOfField()) {
case RIGHT:
origin.setX(renderer1.getRight());
origin.setY(0);
origin.setZ(0);
break;
case LEFT:
origin.setX(renderer1.getLeft());
origin.setY(0);
origin.setZ(0);
break;
case TOP:
origin.setX(0);
origin.setY(renderer1.getTop());
origin.setZ(0);
break;
case BOTTOM:
origin.setX(0);
origin.setY(renderer1.getBottom());
origin.setZ(0);
break;
case FAR:
origin.setX(0);
origin.setY(0);
origin.setZ(renderer1.getFar());
break;
default:
case NEAR:
origin.setX(0);
origin.setY(0);
origin.setZ(renderer1.getNear());
break;
}
// draw at the mouse location
if (input3D.getOutOfField() == OutOfField.NO) {
tmpMatrix4x4_3.setOrigin(origin);
renderer1.setMatrix(tmpMatrix4x4_3);
renderer1.drawCompletingCursor(completingDelay, false);
return false;
}
// draw warner
tmpMatrix4x4_3.setOrigin(origin);
renderer1.setMatrix(tmpMatrix4x4_3);
renderer1.drawCompletingCursor(completingDelay, true);
return true;
// Log.debug("" + input3D.getOutOfField());
}
@Override
public void drawFreeCursor(Renderer renderer1) {
if (input3D.currentlyUseMouse2D()) {
super.drawFreeCursor(renderer1);
} else {
// free point in space
renderer1.drawCursor(PlotterCursor.Type.CROSS3D);
}
}
@Override
public GeoElement getLabelHit(GPoint p, PointerEventType type) {
if (input3D.currentlyUseMouse2D()) {
return super.getLabelHit(p, type);
}
return null;
}
@Override
public void setHits(PointerEventType type) {
if (!input3D.currentlyUseMouse2D() && (input3D.isRightPressed()
|| input3D.isThirdButtonPressed())) {
return;
}
super.setHits(type);
if (input3D.currentlyUseMouse2D()) {
return;
}
// not moving a geo : see if user stays on the same hit to select it
if (input3D.useCompletingDelay()
&& getView().getEuclidianController()
.getMoveMode() == EuclidianController.MOVE_NONE
&& !input3D.hasCompletedGrabbingDelay()) {
long time = System.currentTimeMillis();
hittedGeo.setHitted(
getView().getHits3D().getTopHits()
.getFirstGeo6dofMoveable(),
time, mouse3DScreenPosition);
// reset hits
GeoElement geoToHit = hittedGeo.getGeo();
getView().getHits3D().init(geoToHit);
getView().updateCursor3D(getView().getHits());
getView().getApplication().setMode(EuclidianConstants.MODE_MOVE);
if (hittedGeo.hasLongDelay(time)) {
input3D.setHasCompletedGrabbingDelay(true);
getView().getEuclidianController().handleMovedElement(geoToHit,
false, PointerEventType.TOUCH);
}
}
}
@Override
public boolean isMoveable(GeoElement geo) {
if (input3D.currentlyUseMouse2D()) {
return super.isMoveable(geo);
}
if (geo.isGeoPlane() && geo.isIndependent()
&& !(geo instanceof GeoPlane3DConstant)) {
return true;
}
return super.isMoveable(geo);
}
@Override
public int getCapturingThreshold(PointerEventType type) {
if (input3D.currentlyUseMouse2D()) {
return super.getCapturingThreshold(type);
}
return 5 * super.getCapturingThreshold(type);
}
@Override
public boolean hasMouse() {
if (input3D.currentlyUseMouse2D()) {
return super.hasMouse();
}
return input3D.hasMouse(getView());
}
@Override
public void initAxisAndPlane() {
if (input3D.hasMouseDirection()) {
stylusBeam = new GeoSegment3D(
getView().getKernel().getConstruction());
stylusBeam.setCoord(Coords.O, Coords.VX);
stylusBeam.setObjColor(GColor.GREEN);
stylusBeam.setLineThickness(STYLUS_BEAM_THICKNESS);
stylusBeamIsVisible = false;
stylusBeamDrawable = new DrawSegment3D(getView(), stylusBeam) {
@Override
public boolean isVisible() {
return stylusBeamIsVisible;
}
};
}
}
@Override
public void setZNearest(double zNear) {
if (Double.isNaN(zNear)) {
zNearest = 4;
} else {
zNearest = -zNear;
}
updateStylusBeam();
}
/**
* update stylus beam for moved geo
*/
@Override
public void updateStylusBeamForMovedGeo() {
if (getView().getEuclidianController()
.getMoveMode() == EuclidianController.MOVE_NONE) {
return;
}
if (getView().getEuclidianController()
.getMoveMode() != EuclidianController.MOVE_PLANE) {
getView().getCursor3D().setCoords(input3D.getMouse3DScenePosition(),
false);
GeoElement movedGeo = getView().getEuclidianController()
.getMovedGeoElement();
if (movedGeo != null) {
zNearest = movedGeo.distance(getView().getCursor3D());
}
}
updateStylusBeam();
}
private void updateStylusBeam() {
if (input3D.hasMouseDirection() && !input3D.currentlyUseMouse2D()) {
stylusBeam.setCoord(input3D.getMouse3DScenePosition(),
input3D.getMouse3DDirection().mul(zNearest));
stylusBeamDrawable.setWaitForUpdate();
stylusBeamDrawable.update();
}
}
/**
* set coords to stylus end for given length
*
* @param coords
* returned coords
* @param l
* length
*/
public void getStylusBeamEnd(Coords coords, double l) {
coords.setAdd(input3D.getMouse3DScenePosition(),
coords.setMul(input3D.getMouse3DDirection(), l));
}
@Override
public void resetAllVisualStyles() {
if (input3D.hasMouseDirection()) {
stylusBeamDrawable.setWaitForUpdateVisualStyle(null);
}
}
@Override
public void resetOwnDrawables() {
if (input3D.hasMouseDirection()) {
stylusBeamDrawable.setWaitForReset();
}
}
@Override
public void update() {
if (input3D.hasMouseDirection()) {
if (input3D.currentlyUseMouse2D()) {
stylusBeamIsVisible = false;
} else {
if (input3D.isLeftPressed()) {
// show stylus beam only if object is moved
if (getView().getEuclidianController()
.getMoveMode() == EuclidianController.MOVE_NONE) {
stylusBeamIsVisible = false;
} else {
stylusBeamIsVisible = hasMouse();
}
} else if (input3D.isRightPressed()
|| input3D.isThirdButtonPressed()) {
stylusBeamIsVisible = false;
} else {
stylusBeamIsVisible = hasMouse();
}
}
stylusBeamDrawable.update();
}
}
@Override
public void drawPointAlready(GeoPoint3D point) {
if (input3D.currentlyUseMouse2D()) {
super.drawPointAlready(point);
return;
}
if (point.hasRegion()) {
super.drawPointAlready(point);
} else if (!point.isPointOnPath()
&& point.getMoveMode() != GeoPointND.MOVE_MODE_NONE) {
getView().getRenderer().drawCursor(PlotterCursor.Type.ALREADY_XYZ);
}
}
@Override
public void setDefaultRotAnimation() {
getView().setRotAnimation(input3D.getDefaultRotationOz(),
input3D.getDefaultRotationXOY(), false);
}
@Override
protected void getXMLForStereo(StringBuilder sb, int eyeDistance, int sep) {
if (input3D.shouldStoreStereoToXML()) {
super.getXMLForStereo(sb, eyeDistance, sep);
}
}
@Override
protected void setBackground(GColor color) {
if (input3D.needsGrayBackground()) {
double grayScale = color.getGrayScale();
if (grayScale > GRAY_SCALE_FOR_INPUT3D) {
double factor = GRAY_SCALE_FOR_INPUT3D / grayScale;
GColor darker = GColor.newColor((int) (color.getRed() * factor),
(int) (color.getGreen() * factor),
(int) (color.getBlue() * factor), 255);
getView().setBackground(color, darker);
return;
}
}
super.setBackground(color);
}
@Override
public boolean handleSpaceKey() {
if (getView().getEuclidianController()
.getMoveMode() == EuclidianController.MOVE_NONE) {
hittedGeo.setHitted(getView().getHits3D().getTopHits()
.getFirstGeo6dofMoveable());
// reset hits
GeoElement geoToHit = hittedGeo.getGeo();
getView().getHits3D().init(geoToHit);
getView().updateCursor3D(getView().getHits());
getView().getApplication().setMode(EuclidianConstants.MODE_MOVE);
if (geoToHit != null) {
hittedGeo.consumeLongDelay();
input3D.setHasCompletedGrabbingDelay(true);
getView().getEuclidianController().handleMovedElement(geoToHit,
false, PointerEventType.TOUCH);
return true;
}
return false;
}
releaseGrabbing();
return true;
}
final private void releaseGrabbing() {
getStationaryCoords().consumeLongDelay();
input3D.setHasCompletedGrabbingDelay(false);
getView().getApplication().getSelectionManager()
.clearSelectedGeos(true);
getView().getEuclidianController().endOfWrapMouseReleased(new Hits(),
false, false, PointerEventType.TOUCH);
}
@Override
public void setMode(int mode, ModeSetter m) {
if (input3D.useHandGrabbing() && getView().getEuclidianController()
.getMoveMode() != EuclidianController.MOVE_NONE) {
releaseGrabbing();
}
super.setMode(mode, m);
}
@Override
protected boolean moveCursorIsVisible() {
if (!input3D.hasMouseDirection() || input3D.currentlyUseMouse2D()) {
return super.moveCursorIsVisible();
}
return input3D.isThirdButtonPressed() || input3D.isRightPressed();
}
@Override
protected void drawTranslateViewCursor(Renderer renderer1,
EuclidianCursor cursor, GeoPoint3D cursorOnXOYPlane,
CoordMatrix4x4 cursorMatrix) {
if (!input3D.hasMouseDirection()) {
super.drawTranslateViewCursor(renderer1, cursor, cursorOnXOYPlane,
cursorMatrix);
} else {
if (input3D.currentlyUseMouse2D()) {
GPoint mouseLoc = getView().getEuclidianController()
.getMouseLoc();
if (mouseLoc == null) {
super.drawTranslateViewCursor(renderer1, cursor,
cursorOnXOYPlane, cursorMatrix);
} else {
Coords v;
if (getView()
.getCursor3DType() == EuclidianView3D.CURSOR_DEFAULT) {
// if mouse is over nothing, use mouse coords and screen
// for depth
v = new Coords(mouseLoc.x + renderer1.getLeft(),
-mouseLoc.y + renderer1.getTop(), 0, 1);
} else {
// if mouse is over an object, use its depth and mouse
// coords
Coords eye = renderer1.getPerspEye();
double z = getView().getToScreenMatrix()
.mul(getView().getCursor3D().getCoords()).getZ()
+ 20; // to
// be
// over
double eyeSep = renderer1.getEyeSep();
double x = mouseLoc.x + renderer1.getLeft() + eyeSep
- eye.getX();
double y = -mouseLoc.y + renderer1.getTop()
- eye.getY();
double dz = eye.getZ() - z;
double coeff = dz / eye.getZ();
v = new Coords(x * coeff - eyeSep + eye.getX(),
y * coeff + eye.getY(), z, 1);
}
tmpMatrix4x4_3.setDiagonal3(1 / getView().getScale());
tmpCoords1.setMul(getView().getToSceneMatrix(), v);
tmpMatrix4x4_3.setOrigin(tmpCoords1);
renderer1.setMatrix(tmpMatrix4x4_3);
getView().drawPointAlready(
cursorOnXOYPlane.getRealMoveMode());
renderer1.drawCursor(PlotterCursor.Type.CUBE);
}
} else {
if (input3D.isThirdButtonPressed()) { // third button: translate
// view
// let's scale it a bit more
tmpMatrix4x4_3.setDiagonal3(1.5 / getView().getScale());
// show the cursor at mid beam
input3D.getMouse3DPositionShifted(tmpCoords1);
tmpMatrix4x4_3.setOrigin(tmpCoords1);
renderer1.setMatrix(tmpMatrix4x4_3);
renderer1.drawCursor(PlotterCursor.Type.ALREADY_XYZ);
renderer1.drawCursor(PlotterCursor.Type.CUBE);
} else { // right button: rotate view
// let's scale it a bit more
tmpMatrix4x4_3.setDiagonal3(1.5 / getView().getScale());
tmpCoords1.setMul(getView().getToSceneMatrix(),
input3D.getRightDragElevation().val);
tmpCoords1.setW(0);
tmpCoords1.addInside(
getView().getToSceneMatrix().getOrigin());
tmpMatrix4x4_3.setOrigin(tmpCoords1);
renderer1.setMatrix(tmpMatrix4x4_3);
renderer1.drawCursor(PlotterCursor.Type.ROTATION);
}
}
}
}
private static class HittedGeo {
private GeoElement geo;
private long startTime;
private long lastTime;
private long delay = -1;
private Coords startMousePosition = new Coords(3);
/**
* say if we should forget current
*
* @param time
* current time
* @return true if from last time enough delay has passed to forget
* current
*/
private boolean forgetCurrent(long time) {
return (time - lastTime) * 8 > LONG_DELAY;
}
public void setHitted(GeoElement newGeo, long time,
Coords mousePosition) {
// Log.debug("\nHittedGeo:\n"+getHits3D());
if (newGeo == null || mousePosition == null) { // reinit geo
if (forgetCurrent(time)) {
geo = null;
delay = -1;
// Log.debug("\n -- geo = null");
}
} else {
if (newGeo == geo) { // remember last time
// check if mouse has changed too much: reset the timer
int threshold = 30; // getCapturingThreshold(PointerEventType.TOUCH);
if (Math.abs(mousePosition.getX()
- startMousePosition.getX()) > threshold
|| Math.abs(mousePosition.getY()
- startMousePosition.getY()) > threshold
|| Math.abs(mousePosition.getZ()
- startMousePosition.getZ()) > threshold) {
startTime = time;
startMousePosition.setValues(mousePosition, 3);
} else {
lastTime = time;
}
} else if (geo == null || forgetCurrent(time)) { // change
// geo
geo = newGeo;
startTime = time;
startMousePosition.setValues(mousePosition, 3);
}
// Log.debug("\n "+(time-startTime)+"-- geo = "+geo);
}
}
/**
* set hitted geo
*
* @param newGeo
* hitted geo
*/
public void setHitted(GeoElement newGeo) {
geo = newGeo;
if (newGeo == null) {
delay = -1;
}
}
/**
*
* @return current geo
*/
public GeoElement getGeo() {
return geo;
}
/**
*
* @param time
* current time
* @return true if hit was long enough to process left press
*/
public boolean hasLongDelay(long time) {
if (geo == null) {
delay = -1;
return false;
}
delay = time - startTime;
if (delay > LONG_DELAY) {
consumeLongDelay();
return true;
}
return false;
}
public void consumeLongDelay() {
geo = null; // consume event
delay = -1;
}
public float getCompletingDelay() {
return delay / LONG_DELAY;
}
}
public class StationaryCoords {
private Coords startCoords = new Coords(4);
private Coords currentCoords = new Coords(4);
private long startTime;
private long delay;
private Coords newCoords = Coords.createInhomCoorsInD3();
/**
* New coords.
*/
public StationaryCoords() {
startCoords.setUndefined();
delay = -1;
}
/**
* @param start
* start coordinates
* @param translation
* direction
* @param time
* time
*/
public void setCoords(Coords start, Coords translation, long time) {
newCoords.setValues(start, 3);
newCoords.addInside(translation);
updateCoords(time);
}
/**
* @param start
* start coords
* @param time
* timestamp
*/
public void setCoords(Coords start, long time) {
newCoords.setValues(start, 3);
updateCoords(time);
}
/**
* @param time
* time
*/
public void updateCoords(long time) {
if (startCoords.isDefined()) {
double distance = Math
.abs(startCoords.getX() - newCoords.getX())
+ Math.abs(startCoords.getY() - newCoords.getY())
+ Math.abs(startCoords.getZ() - newCoords.getZ());
// Log.debug("\n -- "+(distance * ((EuclidianView3D)
// ec.view).getScale()));
if (distance * getView().getScale() > 30) {
startCoords.set(newCoords);
startTime = time;
delay = -1;
// Log.debug("\n -- startCoords =\n"+startCoords);
} else {
currentCoords.set(newCoords);
}
} else {
startCoords.set(newCoords);
startTime = time;
delay = -1;
// Log.debug("\n -- startCoords =\n"+startCoords);
}
}
/**
*
* @param time
* current time
* @return true if hit was long enough to process left release
*/
public boolean hasLongDelay(long time) {
if (startCoords.isDefined()) {
delay = time - startTime;
if (delay > LONG_DELAY) {
consumeLongDelay();
return true;
}
} else {
delay = -1;
}
return false;
}
/**
* consume long delay (reset this)
*/
public void consumeLongDelay() {
startCoords.setUndefined(); // consume event
delay = -1;
}
public float getCompletingDelay() {
return delay / LONG_DELAY;
}
public Coords getCurrentCoords() {
return currentCoords;
}
}
public StationaryCoords getStationaryCoords() {
return stationaryCoords;
}
@Override
public boolean useHandGrabbing() {
return input3D.useHandGrabbing() && !input3D.currentlyUseMouse2D();
}
@Override
protected void getHittingOrigin(GPoint mouse, Coords ret) {
if (input3D.hasMouseDirection() && !input3D.currentlyUseMouse2D()) {
ret.set4(input3D.getMouse3DScenePosition());
} else {
super.getHittingOrigin(mouse, ret);
}
}
@Override
public void getHittingDirection(Coords ret) {
if (input3D.hasMouseDirection() && !input3D.currentlyUseMouse2D()) {
ret.set4(input3D.getMouse3DDirection());
} else {
super.getHittingDirection(ret);
}
}
@Override
protected void setPickPointFromMouse(GPoint mouse, Coords pickPoint) {
super.setPickPointFromMouse(mouse, pickPoint);
if (input3D.currentlyUseMouse2D()) {
return;
}
if (mouse instanceof GPointWithZ) {
pickPoint.setZ(((GPointWithZ) mouse).getZ());
}
}
@Override
protected boolean decorationVisible() {
return (!input3D.hasMouseDirection() || input3D.currentlyUseMouse2D())
&& super.decorationVisible();
}
@Override
protected void setPointDecorations(GeoPointND point) {
// no point decoration if using stylus-like input
if (!input3D.hasMouseDirection() || input3D.currentlyUseMouse2D()) {
super.setPointDecorations(point);
}
}
@Override
protected boolean drawCrossForFreePoint() {
return !input3D.hasMouseDirection() || input3D.currentlyUseMouse2D();
}
@Override
public boolean isStereoBuffered() {
return input3D.isStereoBuffered();
}
@Override
public boolean wantsStereo() {
return input3D.wantsStereo();
}
@Override
public boolean useOnlyProjectionGlasses() {
return input3D.useOnlyProjectionGlasses();
}
@Override
public boolean shouldDrawCursor() {
return super.shouldDrawCursor() && hasMouse();
}
}
| [
"[email protected]"
] | |
6b6158b9eb56272b623744d5d6e8ddc78b5f7d84 | 8305480bb48e9f6737303e01f501e190bedce2e5 | /src/com/example/words/view/LastWordTile.java | 58a554e0a7f1c89d4a723e61c56d1c7ec501d850 | [] | no_license | jkgneu12/Words | e7b001541ae383e39ec47b44d19fcdfa0db0c861 | 3c6a93e10fc75531b6ac1f194c2cf4695d8f6e9d | refs/heads/master | 2021-01-25T04:57:35.792876 | 2012-09-26T03:07:27 | 2012-09-26T03:07:27 | 5,135,985 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 919 | java | package com.example.words.view;
import android.graphics.drawable.Drawable;
import com.example.words.R;
import com.example.words.activity.GameActivity;
import com.example.words.activity.GameFragment;
public class LastWordTile extends Tile {
private int index;
public LastWordTile(GameActivity activity, GameFragment fragment, String text, int index) {
super(activity, fragment, text);
this.index = index;
}
@Override
public boolean isPartOfLastWord() {
return true;
}
@Override
public String toString() {
return "LastWord" + super.toString();
}
public int getIndex() {
return index;
}
protected Drawable getBackgroundDrawable(){
return activity.getResources().getDrawable(R.drawable.last_word_tile_background);
}
@Override
protected Drawable getSelectedBackgroundDrawable() {
return activity.getResources().getDrawable(R.drawable.selected_last_word_tile_background);
}
}
| [
"[email protected]"
] | |
1ac82fd33ca6ce0c092d3034567e31799446f192 | b452c2fdd392b7ea069fb6e52e8a41f38b87b7a9 | /src/main/java/my/crud/service/ProductServiceImpl.java | 8768da067b7041877ce3d2223dda0ffa625c69ee | [] | no_license | mpestka/crud | 3b41913a6af892e52f9593526784ddd41ff662a2 | 97f81b1a4aa744e9a6f301705ea5269ff81f84d5 | refs/heads/master | 2021-04-13T12:50:27.151922 | 2020-03-27T15:17:10 | 2020-03-27T15:17:10 | 249,164,710 | 0 | 0 | null | 2020-03-22T16:16:26 | 2020-03-22T11:00:43 | Java | UTF-8 | Java | false | false | 2,083 | java |
package my.crud.service;
import java.sql.Timestamp;
import java.time.Clock;
import java.util.List;
import java.util.Optional;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import my.crud.domain.Product;
import my.crud.repository.ProductRepository;
@Service
@Transactional
public class ProductServiceImpl implements ProductService {
private Clock clock;
private ProductRepository productRepository;
@Autowired
public ProductServiceImpl(Clock clock, ProductRepository productRepository) {
this.clock = clock;
this.productRepository = productRepository;
}
public List<Product> getAllActive() {
return productRepository.findAllActive();
}
public Product create(Product product) {
final Product created = product.toBuilder()
.id(null)
.deleted(null)
.created(now())
.build();
return productRepository.save(created);
}
public Optional<Product> update(Product product) {
Assert.notNull(product.getId(), "Product id required");
Assert.isNull(product.getDeleted(), "To delete product use delete api");
final Optional<Product> dbProduct = productRepository.findById(product.getId());
if (!dbProduct.isPresent() || dbProduct.get().getDeleted() != null) {
return Optional.empty();
}
return Optional.of(productRepository.save(product));
}
public boolean softDeleteById(Long id) {
final Optional<Product> product = productRepository.findById(id);
if (!product.isPresent() || product.get().getDeleted() != null) {
return false;
}
productRepository.softDeleteById(id, now());
return true;
}
private Timestamp now() {
return Timestamp.from(clock.instant());
}
}
| [
"[email protected]"
] | |
3e1df976a537b2006f103e82bba1af3edf10b20a | d2f6e5a69179ad111c1bbae5d393b535d1675bf6 | /app/src/main/java/com/example/aumarmourad/testyoutube/EarplugReceiver.java | 1d233e568fc941a993d2f9e847d40729cea2a674 | [] | no_license | Mourad95/AdroidTestYouTube | e3695b45ef8fbdeb4baf93aa5e5c00139bb61754 | 7aede1152c9bb30dff57fe4067b0114b83929553 | refs/heads/master | 2020-03-10T13:46:42.743412 | 2018-04-13T14:26:04 | 2018-04-13T14:26:04 | 129,407,595 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 813 | java | package com.example.aumarmourad.testyoutube;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* Created by aumarmourad on 13/04/2018.
*/
class EarplugReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getIntExtra("state",-1) ==1) {
Log.d("ecouteur", "je suis dans broadcast receiver");
/*Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("com.google.android.youtube");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
if (launchIntent != null) {
context.startActivity(launchIntent);
}*/
}
}
}
| [
"[email protected]"
] | |
735015431eb83a71f9f28d3634fa930d74e78ce4 | 49e27cb021a2831694209dbad1b6d90460fc4b0d | /DealerCar/src/br/com/dealercar/domain/itensrevisao/Componentes.java | 70e21a8d0a621dfc4b1a136f897218d8d54bcf3c | [] | no_license | legionario07/DealerCarProject | 22f06b8e85fe14e5a35bc0cee7bb2083b9f7538a | 3be321af60582ffa8b5898782bac410fc3910fd6 | refs/heads/master | 2020-04-06T07:04:56.269188 | 2016-07-19T19:03:31 | 2016-07-19T19:03:31 | 40,949,223 | 0 | 1 | null | null | null | null | ISO-8859-1 | Java | false | false | 736 | java | package br.com.dealercar.domain.itensrevisao;
import java.io.Serializable;
import br.com.dealercar.domain.EntidadeDominio;
/**
* Classe herdadas pelos itens de Revisão
* @author Paulinho
*
*/
public class Componentes extends EntidadeDominio implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String situacao;
public Componentes() {
}
public String getSituacao() {
return situacao;
}
public void setSituacao(String situacao) {
this.situacao = situacao;
}
@Override
public String toString() {
StringBuffer retorno = new StringBuffer();
retorno.append("\nItens Verificados: ");
return retorno.toString();
}
}
| [
"[email protected]"
] | |
110c566bffada2af0cfad03db83da404ab97b9d8 | 2fc7bfd2116e41bc7e09fb852fd638252f9de8cf | /src/Assignment_2/Map_Main.java | 284de646a9d143db26374bdcf2cdac61bd99d286 | [
"Unlicense"
] | permissive | Hodginson/COMP261-Auckland-Road-Map-V2 | 6d2a55959c41dfd334dcdcb78cb89316664dda45 | 76af82cf8af3e715aaee0ccd69b9628c77807fd8 | refs/heads/master | 2020-03-31T15:08:51.388094 | 2018-10-10T02:52:54 | 2018-10-10T02:52:54 | 152,326,102 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 25,072 | java | package Assignment_2;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
public class Map_Main extends GUI {
Location origin;
double scale = 30;
double north = Double.NEGATIVE_INFINITY;
double south = Double.POSITIVE_INFINITY;
double east = Double.NEGATIVE_INFINITY;
double west = Double.POSITIVE_INFINITY;
Map<Integer, Create_Nodes> nodesMap = new HashMap<Integer, Create_Nodes>(); //a map to store the nodes
Map<Integer, Create_Roads> roadsMap = new HashMap<Integer, Create_Roads>(); // a map to store the roads
Set<Create_Polygons> polygonSet = new HashSet<Create_Polygons>();
Map<Integer, PolygonColor> colours = new TreeMap<Integer,PolygonColor>();//the colour set for the polygons
Map<Integer, Create_Restrictions> Restrictions = new HashMap<Integer, Create_Restrictions>();
Set<String> BothRoadNameSet = new HashSet<String>();
// for the trie tree method
Trie_tree trieRoot = new Trie_tree();
List<Create_Roads> SelectedRoads = new ArrayList<Create_Roads>();
//for the quad tree
Create_Nodes currentNode;
Quad_Tree quadRoot = null;
//for A* search
boolean find_Route = false;
Create_Nodes StartingPoint;
Create_Nodes FinishingPoint;
int currentNodeSize = 10;
ArrayList<Create_Nodes> currentNodes;
List<Create_Segments> PathSegments;
//for the Articulation Points
Set<Create_Nodes> articulationPoints = new HashSet<Create_Nodes>();
List<Create_Nodes> notVisited = new ArrayList<Create_Nodes>();
Stack<Articulation_Points> articulationStack = new Stack<Articulation_Points>();
public Map_Main() { // defines the Color set for polygons
colours.put(2, new PolygonColor(142, 145, 142)); //city - Light Grey
colours.put(5, new PolygonColor(174, 40, 58)); //Car park - Reddish purple
colours.put(7, new PolygonColor(66, 66, 66)); //Airport - Dark grey
colours.put(8, new PolygonColor(226, 126, 4)); //Shopping Center - Orange
colours.put(10, new PolygonColor(250, 255, 0)); //University - Yellow
colours.put(11, new PolygonColor(173, 24, 24)); //Hospital - Red
colours.put(14, new PolygonColor(206, 206, 202)); //Airport Runway - Grey
colours.put(19, new PolygonColor(163, 108, 26)); //Man made area - Brown/Orange
colours.put(22, new PolygonColor(79, 188, 78)); //National park - Green
colours.put(23, new PolygonColor(9, 232, 42)); //city park - Green
colours.put(24, new PolygonColor(0, 255, 4)); //golf course - Light Green
colours.put(25, new PolygonColor(12, 209, 137)); //sport - turquoise
colours.put(26, new PolygonColor(125, 61, 165)); //Cemetery - Purple
colours.put(30, new PolygonColor(0, 178, 38)); //state park - Green
colours.put(40, new PolygonColor(65, 103, 226)); // OCEAN - Blue
colours.put(60, new PolygonColor(7, 244, 189)); //lake baby blue
colours.put(62, new PolygonColor(7, 244, 189)); //lake
colours.put(64, new PolygonColor(65, 172, 226)); // RIVERS light blue
colours.put(65, new PolygonColor(65, 172, 226)); // RIVERS
colours.put(69, new PolygonColor(65, 172, 226)); // RIVERS
colours.put(71, new PolygonColor(65, 172, 226)); // RIVERS
colours.put(72, new PolygonColor(65, 172, 226)); // RIVERS
colours.put(80, new PolygonColor(0, 68, 1)); // Woods - dark green
}
protected void find_RoutePressed() {
if (find_Route) {
find_Route = false;
currentNode = null;
getTextOutputArea().setText("");
} else {
find_Route = true;
currentNode = null;
StartingPoint = null;
FinishingPoint = null;
getTextOutputArea().setText("Select the two nodes you want to find the route to");
}
}
private AStarSearch findShortestRoute(Create_Nodes startNode, Create_Nodes endNode) {
Set<AStarSearch> visitedSearch = new HashSet<AStarSearch>();
Set<Create_Nodes> NodesVisited = new HashSet<Create_Nodes>();
Queue<AStarSearch> fringe = new PriorityQueue<AStarSearch>();
AStarSearch start = new AStarSearch(startNode, null, 0, startNode.DistanceToNode(endNode));
fringe.add(start);
while (fringe.size() > 0) {
AStarSearch searchNode = fringe.poll(); // dequeue the highest node, and process it if is not been visited
if (searchNode.getNodes().equals(endNode)) { // if the node equals goal return the node
return searchNode;
}
double costToHere = searchNode.getCurrentCost(); // calculates the current cost
if (!visitedSearch.contains(searchNode)) {
visitedSearch.add(searchNode); // add the node to the visited set to indicate it has been visited
}
if (searchNode.getNodes() != null) {
NodesVisited.add(searchNode.getNodes());
}
Map<Create_Nodes, Create_Segments> neighbours = searchNode.getNodes().getAdjacentNodes(); // add its neighbors to the fringe
if (neighbours.size() > 0) {
for (Create_Nodes entryPoint : neighbours.keySet()) {// Check the restrictions
Create_Restrictions restriction = Restrictions.get(entryPoint.getId());
//check if the road is one way
for (Create_Segments Segments : entryPoint.getSegments()) {
if (restriction != null) { // check if there are any restrictions that will cause doubling back
if (restriction.getNodeID() == entryPoint.getId()
&& restriction.getStartNodeID() == searchNode.getNodes().getId()
&& restriction.getEndRoadID() == Segments.getRoad().getId()) {
NodesVisited.add(entryPoint);
break;
}
}
}
}
// Iterate though nodes while taking into account all of the restrictions
for (Create_Nodes entryPoint : neighbours.keySet()) {
for (Create_Segments Segments : entryPoint.getSegments()) {
if (Segments.getRoad().isOneway()) {
if (Segments.getNodeEnd().equals(entryPoint)) {
Double segmentLength = neighbours.get(entryPoint).getLength();
Double estimateDistance = entryPoint.DistanceToNode(endNode);
if (!NodesVisited.contains(entryPoint)) {
AStarSearch addNeighbour = new AStarSearch(entryPoint, searchNode, costToHere + segmentLength, costToHere + estimateDistance);
fringe.add(addNeighbour);
}
}
} else { // the road is not one way
Double segmentLength = neighbours.get(entryPoint).getLength();
Double estimateDistance = entryPoint.DistanceToNode(endNode);
if (!NodesVisited.contains(entryPoint)) {
AStarSearch addNeighbour = new AStarSearch(entryPoint, searchNode, costToHere + segmentLength, costToHere + estimateDistance);
fringe.add(addNeighbour);
}
}
}
}
}
}
return null;
}
protected void setOrigin() { //finds the centre point of the map
double[] Map_Limits = this.setMap_Limits();
scale = Math.min(400 / (Map_Limits[1] - Map_Limits[0]),
400 / (Map_Limits[2] - Map_Limits[3]));
origin = new Location(Map_Limits[0], Map_Limits[2]);
}
@Override
protected void onLoad(File nodes, File roads, File segments, File polygons, File restrictions) {
this.loadData(nodes, roads, segments, polygons, restrictions);
this.setOrigin();
this.findArticulationPoints();
}
//loads the data from the files, checks if polygons is null
protected void loadData(File nodes, File roads, File segments, File polygons, File restrictions) {
this.loadRoads(roads);
this.loadNodes(nodes);
this.loadSegments(segments);
if (polygons != null) {
this.loadPolygons(polygons);
}
if (restrictions != null) {
this.loadRestrictions(polygons);
}
}
//load the nodes from the Node file, adds them to the Map
protected void loadNodes(File nodes) {
try {
BufferedReader data = new BufferedReader(new FileReader(nodes));
while (data.ready()) {
String line = data.readLine(); // Read the data and creates a node
if (line.length() > 0) {
Create_Nodes node = new Create_Nodes(line); // Add the node to the node map
nodesMap.put(node.getId(), node);
}
}
// Generates a quad-tree structure for the nodes
double[] bounds = this.setMap_Limits();
quadRoot = new Quad_Tree(new Location(bounds[0], bounds[2]), new Location(bounds[1], bounds[3]));
// Add all the nodes to the quad-tree
for(Create_Nodes node : nodesMap.values()) {
quadRoot.addNode(node);
}
data.close();
} catch (IOException e) {
System.out.printf("Failed to open file: %s, %s", e.getMessage(),
e.getStackTrace());
}
}
//loads the roads from text file, adds them to the Map
protected void loadRoads(File roads) {
try {
BufferedReader data = new BufferedReader(new FileReader(roads));
data.readLine();// skips the first line as it contains headers
while (data.ready()) {
String line = data.readLine(); // Read the data and creates a road
Create_Roads road = new Create_Roads(line); //adds the road to the map
roadsMap.put(road.getId(), road);
trieRoot.addRoad(road);
}
data.close();
} catch (IOException e) {
System.out.printf("Failed to load: %s, %s", e.getMessage(),e.getStackTrace());//prints the path if it fails
}
}
//load all segments from text file and adds them to "nodeMap" & "roadMap"
protected void loadSegments(File segments) {
try {
BufferedReader data = new BufferedReader(new FileReader(segments));
data.readLine(); // skips the first line as it contains headers
while (data.ready()) {
String line = data.readLine();
Create_Segments segment = new Create_Segments(line, roadsMap, nodesMap);
Create_Roads road = segment.getRoad();// If a road exists add a new segment
if (road != null) {
road.addSegment(segment);
}
Create_Nodes nodeStart = segment.getNodeStart(); // If a node exists then add a new segment
if (nodeStart != null) {
nodeStart.addSegment(segment);
}
Create_Nodes nodeEnd = segment.getNodeEnd();
if (nodeEnd != null) {
nodeEnd.addSegment(segment);
}
}
data.close();
} catch (IOException e) {
System.out.printf("Failed to load: %s, %s", e.getMessage(),e.getStackTrace());
}
}
//load polygon file into memory
protected void loadPolygons(File polygons){
Integer polygonType =0;
String label = "";
Integer endLevel = 0;
Integer cityIndex = 0;
List<Location> coordinates = new ArrayList<Location>();
Set<Integer> type = new TreeSet<Integer>();
try {
BufferedReader data = new BufferedReader(new FileReader(polygons));
while (data.ready()){
String line = data.readLine();
if (line.startsWith("Type=")){
polygonType = Integer.parseInt(line.substring(7),16);
// Add polyType to a temp set, to check how many colors to use
type.add(polygonType);
} else if (line.startsWith("Label=")) {
label = line.substring(6);
} else if (line.startsWith("EndLevel=")) {
endLevel = Integer.parseInt(line.substring(9));
} else if (line.startsWith("CityIdx=")) {
cityIndex = Integer.parseInt(line.substring(8));
} else if (line.startsWith("Data0=")) {
String strCoords = line.substring(6);
coordinates.clear();
String[] coordArray = strCoords.substring(1,strCoords.length()-2).split("\\),\\(",-1);// Splits the coordList String and separates them into X and Y
for (int i=0;i<coordArray.length;i++){
Double X = Double.parseDouble(coordArray[i].split(",")[0]);
Double Y = Double.parseDouble(coordArray[i].split(",")[1]);
coordinates.add(Location.newFromLatLon(X, Y));
}
Create_Polygons polyShape = new Create_Polygons(polygonType, endLevel, label, cityIndex, coordinates, colours.get(polygonType));
polygonSet.add(polyShape);
}
}
data.close();
}
catch (IOException e){
System.out.printf("Failed to load %s, %s", e.getMessage(), e.getStackTrace());
}
}
private void loadRestrictions(File restrictions) {
try {
BufferedReader data = new BufferedReader(new FileReader(restrictions));
data.readLine();
while (data.ready()) {
String line = data.readLine();
String[] l = line.split("\t");
int nodeID = Integer.parseInt(l[2]);
Create_Restrictions restriction = new Create_Restrictions(line);
Restrictions.put(nodeID, restriction);
}
data.close();
} catch (IOException e) {
System.out.printf("filed to open file %s, %s", e.getMessage(), e.getStackTrace());
}
}
// set the max and min location
protected double[] setMap_Limits() {
for (Create_Nodes nodes : nodesMap.values()) {
if (nodes.getLocation().y > north)
north = nodes.getLocation().y;
if (nodes.getLocation().x > east)
east = nodes.getLocation().x;
if (nodes.getLocation().y < south)
south = nodes.getLocation().y;
if (nodes.getLocation().x < west)
west = nodes.getLocation().x;
}
return new double[] { west, east, north, south };
}
@Override
protected void onMove(Move m) { //called when a button on the gui is pressed
double zoomFactor = 1.5;
double factor = 100/scale;
switch (m) {
case NORTH: {
origin = origin.moveBy(0, factor);
this.redraw();
break;
}
case SOUTH: {
origin = origin.moveBy(0, -factor);
this.redraw();
break;
}
case EAST: {
origin = origin.moveBy(factor, 0);
this.redraw();
break;
}
case WEST: {
origin = origin.moveBy(-factor, 0);
this.redraw();
break;
}
case ZOOM_IN: {
double NewOrigin = super.getDrawingAreaDimension().getHeight()
/ scale * (zoomFactor - 1) / zoomFactor / 2;
double a = scale * (zoomFactor - 1) / zoomFactor / 2;
System.out.printf("Failed to load %s, %s", NewOrigin,a);
origin = new Location(origin.x + NewOrigin, origin.y - NewOrigin);
scale = scale * zoomFactor;
this.redraw();
break;
}
case ZOOM_OUT: {
scale = scale / zoomFactor;
double newOrigin = super.getDrawingAreaDimension().getHeight()
/ scale * (zoomFactor - 1) / zoomFactor / 2;
origin = new Location(origin.x - newOrigin, origin.y + newOrigin);
this.redraw();
break;
}
}
return;
}
@Override
protected void redraw(Graphics g) {
this.draw(g, origin, scale,
super.getDrawingAreaDimension().getHeight(), super
.getDrawingAreaDimension().getWidth());
}
private void setStartingPoint(Create_Nodes node) {
this.StartingPoint = node;
}
private void setFinishingPoint(Create_Nodes node) {
this.FinishingPoint = node;
}
@Override
protected void onClick(MouseEvent click) {
// When the user clicks the coordinates are found
if (click.getButton() == 1) {
int x = click.getPoint().x;
int y = click.getPoint().y;
Location clickedCoordinates = Location.newFromPoint(new Point(x, y), this.origin, this.scale);
// Find quad tree in area then query the children for intersections
Quad_Tree childNode = quadRoot.getCoordinates(clickedCoordinates.x, clickedCoordinates.y);
for (Create_Nodes node : childNode.getNodeList()) {
if (node.getLocation().isClose(clickedCoordinates, 0.08)) {//the margin of error for a click if the quad node will find it. initially had it too high so selecting nodes was tough as it would always auto select
List<Create_Segments> pathsegmentList = node.getSegments();
for (Create_Segments seg : pathsegmentList) {
BothRoadNameSet.add(seg.getRoad().getName());
}
if (!find_Route) {
int nodeID = node.getId();
String selectedNode = String.format("Intersection For: ",nodeID);
getTextOutputArea().setText(selectedNode);
List<Create_Segments> segmentList = node.getSegments();
Set<String> RoadNameSet = new HashSet<String>();
for (Create_Segments seg : segmentList) {
RoadNameSet.add(seg.getRoad().getName());
}
for (String road : RoadNameSet) {
getTextOutputArea().append(road + " ");
break;
}
currentNode = node;
} else if (find_Route) { // find path mode is active
if(!(StartingPoint == null) && !(FinishingPoint == null)){
StartingPoint = null;
FinishingPoint = null;
}
if (StartingPoint == null) {
setStartingPoint(node);
int startID = StartingPoint.getId();
String startNode = String.format("From: ", startID);
getTextOutputArea().setText(startNode);
List<Create_Segments> segmentList = node.getSegments();
Set<String> FirstRoadNameSet = new HashSet<String>();
for (Create_Segments seg : segmentList) {
FirstRoadNameSet.add(seg.getRoad().getName());
}
for (String road : FirstRoadNameSet) {
getTextOutputArea().append(road + " ");
break;
}
} else if (StartingPoint != null && FinishingPoint == null) {
setFinishingPoint(node);
List<Create_Segments> segmentList = node.getSegments();
Set<String> SecondRoadNameSet = new HashSet<String>();
for (Create_Segments seg : segmentList) {
SecondRoadNameSet.add(seg.getRoad().getName());
}
for (String road : SecondRoadNameSet) {
getTextOutputArea().append("To: " + road + " \n");
}
}
if (StartingPoint != null && FinishingPoint != null) { // if nodes are active look up for shortest path
currentNodes = new ArrayList<Create_Nodes>();
currentNodes.add(StartingPoint);
PathSegments = new ArrayList<Create_Segments>();
AStarSearch endNode = findShortestRoute(StartingPoint, FinishingPoint);
if (endNode != null) { // check if there is possible route
currentNodes.add(StartingPoint);
currentNodes.add(FinishingPoint);
while (endNode.getFromNode() != null) {
for (Create_Segments seg : endNode.getNodes().getSegments()) { // selects only the segments which are on the path
if ((seg.getNodeEnd().getId() == endNode.getNodes().getId() || seg.getNodeStart().getId() == endNode.getNodes().getId())
&& ((seg.getNodeStart().getId() == endNode.getFromNode().getNodes().getId()) || seg.getNodeEnd().getId() == endNode.getFromNode().getNodes()
.getId())) {
PathSegments.add(seg);
}
}
currentNodes.add(endNode.getNodes());
endNode = endNode.getFromNode();
}
Collections.reverse(currentNodes); // Reverse the node list ;-)
}
}
}
}
}
}
}
@Override
protected void onSearch() { //called when the search box has something entered or removed from it
String RequiredRoad = getSearchBox().getText();
String SearchString = "";
Set<String> roadNames = new HashSet<String>();
if (RequiredRoad.length() > 0) {
Trie_tree node = trieRoot.FindRoad(RequiredRoad);
if (node != null) {
SelectedRoads = node.getRoads();
for (Create_Roads road : SelectedRoads) {
if (!roadNames.contains(road.getName())) {
SearchString = SearchString + "\n" + road.getName();
roadNames.add(road.getName());
}
}
getTextOutputArea().setText(SearchString);
} else
SelectedRoads.clear();
}
}
private void findArticulationPoints() {
// copy all the unvisited nodes to a set
for (Create_Nodes node : nodesMap.values()) {
notVisited.add(node);
}
// creates a new empty set for the articulation points
while (notVisited.size() > 0) {
int numberOfSubTrees = 0; //number of subtrees
Create_Nodes startNode = null; //root node
int count = 0;
for (int i=0; i<notVisited.size(); i++ ) {
notVisited.get(i).resetNodeDepth();
if (count == 0) {
startNode = notVisited.get(i);
}
count++;
}
// root case
for (Create_Nodes node : startNode.getAllAdjacent().keySet()) {
notVisited.remove(startNode); // removes the startNode from the unVisited list
if (node.getNodeDepth() == Integer.MAX_VALUE) {
ArticulationPoints(node, startNode);
numberOfSubTrees++;
}
}
if (numberOfSubTrees > 1) {
articulationPoints.add(startNode);
}
}
}
private void ArticulationPoints(Create_Nodes firstNode, Create_Nodes root) {//the iteration method
articulationStack.push(new Articulation_Points(firstNode, 1, new Articulation_Points(root, 0, null)));
while (!articulationStack.isEmpty()) {
Articulation_Points ArtPoints = articulationStack.peek(); // looks at previous node
Create_Nodes node = ArtPoints.getNode();
if (ArtPoints.children() == null) {
ArrayDeque<Create_Nodes> children = new ArrayDeque<Create_Nodes>();
ArtPoints.setChildren(children);
ArtPoints.setReachBack(ArtPoints.getPointdepth());
node.setNodeDepth(ArtPoints.getPointdepth());
for (Create_Nodes neighbour : node.getAllAdjacent().keySet()) {
if (neighbour != ArtPoints.getParent().getNode()) {
children.offer(neighbour);
}
}
} else if (!ArtPoints.children().isEmpty()) {
Create_Nodes child = ArtPoints.children().poll();
if (child.getNodeDepth() < Integer.MAX_VALUE) {
ArtPoints.setReachBack(Math.min(ArtPoints.getReachBack(), child.getNodeDepth()));
} else {
articulationStack.push(new Articulation_Points(child, node.getNodeDepth() + 1, ArtPoints));
}
} else {
if (node != firstNode) {
if (ArtPoints.getReachBack() >= ArtPoints.getParent().getPointdepth()) {
articulationPoints.add(ArtPoints.getParent().getNode());
}
ArtPoints.getParent().setReachBack(Math.min(ArtPoints.getParent().getReachBack(), ArtPoints.getReachBack()));
}
notVisited.remove(articulationStack.pop().getNode());
}
}
}
protected void draw(Graphics g, Location origin, double scale, double screenH, double screenW) {
this.origin = origin;
this.scale = scale;
int nodeSize = (int) Math.min(.2 * (scale), 7);
if (nodesMap.size() > 0) {
// Draw the polygons
for (Create_Polygons polygons : polygonSet) {
for (Integer entry : colours.keySet()) {
polygons.draw(g, origin, scale, entry);
}
}
// Draw the segments
for (Create_Roads roads : roadsMap.values()) {
if (SelectedRoads.contains(roads)) {
g.setColor(Color.RED);
for (Create_Segments segments : roads.getSegments()) {
segments.draw(g, origin, scale, 1);
}
} else {
g.setColor(Color.BLACK);
for (Create_Segments segments : roads.getSegments()) {
segments.draw(g, origin, scale, 1);
}
}
}
// Draw the nodes
for (Create_Nodes nodes : nodesMap.values()) {
if (!articulationPoints.contains(nodes)) { // check if node belongs to articulation points
if (nodes == currentNode) {
g.setColor(Color.RED);
} else {
g.setColor(Color.BLUE);
}
nodes.draw(g, origin, scale, nodeSize);
}
}
if (find_Route && StartingPoint != null && FinishingPoint != null && currentNodes.size() > 0 && PathSegments.size() > 0) { // Draw start node if
for (Create_Segments Segments : PathSegments) { // draw segments
g.setColor(Color.green);
Segments.draw(g, origin, scale, 1);
}
Set<String> roadNames = new HashSet<String>();
Double totalDistance = 0.0;
for (int i = 0; i < currentNodes.size() - 1; i++) {
for (Create_Segments Segments : currentNodes.get(i).getSegments()) {
if (Segments.getNodeEnd().equals(currentNodes.get(i + 1))) { // if it's an end node
String roadName = Segments.getRoad().getName();
double Distance = Segments.getLength();
if (!roadNames.contains(roadName)) {
getTextOutputArea().append(String.format("%s: %.2fkm %n", roadName, Distance));
roadNames.add(roadName);
totalDistance += Distance;
}
} else if (Segments.getNodeStart().equals(currentNodes.get(i + 1))) { // if it's a start node
String roadName = Segments.getRoad().getName();
double Distance = Segments.getLength();
if (!roadNames.contains(roadName)) {
getTextOutputArea().append(String.format("%s: %.2fkm %n", roadName, Distance));
roadNames.add(roadName);
totalDistance += Distance;
}
}
}
}
getTextOutputArea().append(String.format("Total Distance: %.2fkm %n", totalDistance));
//drawing nodes
for (Create_Nodes node : currentNodes) { // draw nodes
g.setColor(Color.yellow);
node.draw(g, origin, scale, currentNodeSize);
}
}
if (find_Route && StartingPoint != null) { // Draw start node if findPath is active
StartingPoint.draw(g, origin, scale, currentNodeSize);
}
if (find_Route && FinishingPoint != null) { // Draw arrival node if findPath is active
FinishingPoint.draw(g, origin, scale, currentNodeSize);
}
//Draw articulation points
for (Create_Nodes ArticulationNodes : articulationPoints) {
if (ArticulationNodes == currentNode) {
g.setColor(Color.RED);
} else if(ArticulationNodes == StartingPoint || ArticulationNodes == FinishingPoint ) {
g.setColor(Color.orange);
}else{
g.setColor(Color.cyan);
}
ArticulationNodes.draw(g, origin, scale, nodeSize + 3);
}
}
}
public static void main(String[] args) {
new Map_Main();
}
}
| [
"[email protected]"
] | |
90dc003d9a6bb07f7cc5aaeaaa908d3d2a2daf3f | 72a5f9413b78947206564ec4d026af50f7eb6480 | /Hashtable/HW8_StarterCode/HW8_ExtraCredit.java | d5772d8d98c5b2c3e169f982cfc613b8c67e86ba | [] | no_license | peiranli/Data-Structures | 78b67fbf1ffc05e770c9ab2ceacf8a7da220233e | e15b9706003f65c0626f8e3d1f31ca87e3abcefc | refs/heads/master | 2020-06-20T10:06:48.363035 | 2019-09-08T05:11:15 | 2019-09-08T05:11:15 | 197,088,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,722 | java | // *
// NAME: <Peiran Li>
// ID: <A92036065>
// LOGIN: <cs12smz>
// *
package hw8;
import java.io.*;
import java.util.*;
/**
* class to find anagrams of a word
* @author PeiranLi
* @version 1.0
* @since 5-22-2016
*/
public class HW8_ExtraCredit {
/**
* inner string pair class
* contains original word and the key
*
*/
protected static class StringPair{
//instance variables
private String original;
private String key;
/**
* constructor
* @param original original word
* @param key the key of the original word
*/
public StringPair(String original, String key){
this.original = original;
this.key = key;
}
/**
* getter of key
* @return the key
*/
public String getKey(){
return this.key;
}
/**
* getter of original word
* @return original word
*/
public String getOrigin(){
return this.original;
}
}
/**
* inner hash table class
*/
protected static class HashTable {
//array of linked list
private LinkedList<StringPair>[] myList;
private int nelems; //Number of element stored in the hash table
/**
* Constructor for hash table
* @param Initial size of the hash table
*/
@SuppressWarnings("unchecked")
public HashTable(int size) {
//Initialize
this.nelems = 0;
myList = new LinkedList[size];
//initialize array
for(int i = 0; i< size; i++){
myList[i] = new LinkedList<StringPair>();
}
}
/**
* Inserts element in the hash table.
* should return true or false,
* depending on whether it was inserted or not.
* Throw a NullPointerException if a null value is passed.
* @param value the element to insert
* @return Return true if item is inserted, false if it already exists.
* @throws NullPointerException
*/
public boolean insert(String original, String key) {
//if original word is null throw NullPointerException
if(original == null)
throw new NullPointerException();
//if load factor is greater than 2/3, double size and rehash
if(loadFactor()>(2.0/3)){
this.rehash();
}
//hash value
int hash = hashValue(key, myList.length);
//if original already exists, return false
if(lookup(original,key))
return false;
//else add it into hash table
else{
myList[hash].add(new StringPair(original,key));
this.nelems++;
}
return true;
}
/**
* Use the hash table to determine where i is,
* delete it from the hash table.
* (an item cannot be deleted if it does not exist in the hash table).
* @param value the element to delete
* @throws Throw a NullPointerException if a null value is passed.
* @return should return true if the item is deleted,
* false if it cannot be deleted
*/
public boolean delete(String value,String key) {
//if the value is null, throw NullPointerException
if(value == null)
throw new NullPointerException();
//get the hash key
int hash = hashValue(key, myList.length);
//if value does not exist, return false
if(!lookup(value,key))
return false;
//else find it and delete it
else{
for(int i = 0; i < myList[hash].size(); i++){
if(myList[hash].get(i).getOrigin().equals(value))
myList[hash].remove(i);
}
this.nelems--;
}
return true;
}
/**
* Uses the hash table to determine if i is in the data structure.
* @return should return true or false, depending on whether the item exists.
* @throws Throw a NullPointerException if a null value is passed.
* @param value the element to find
*/
public boolean lookup(String value,String key) {
//if the value is null, throw NullPointerException
if(value == null)
throw new NullPointerException();
//get hash key
int hash = hashValue(key, myList.length);
//go through and find it
for(int i = 0; i < myList[hash].size();i++){
if(myList[hash].get(i).getOrigin().equals(value))
return true;
}
return false;
}
/**
* getter of linked list at given key
* @param key the bucket of hash table
* @return the linked list at given key
*/
public LinkedList<StringPair> getList(String key){
int hashvalue = this.hashValue(key, myList.length);
return myList[hashvalue];
}
/**
* @return the number of elements currently stored in the hash table
*/
public int getSize() {
return this.nelems;
}
/**
* help method to get hash value
* @param key the element key
* @param tableSize the size of hash table
* @return hash value of the key
*/
private int hashValue(String key, int tableSize){
int hashValue = 0;
//add all the chars up
for(int i = 0; i < key.length(); i++){
int letter = key.charAt(i);
hashValue = (hashValue*27+letter)%tableSize;
}
return hashValue;
}
/**
* get the load factor
* @return load factor
*/
private double loadFactor(){
double sum = 0;
for(int i = 0; i < myList.length;i++){
sum += myList[i].size();
}
return sum/(double)myList.length;
}
/**
*
* @return a new expanded linked list
*/
@SuppressWarnings("unchecked")
private LinkedList<StringPair>[] expand(){
//double the size
LinkedList<StringPair>[] newList = new LinkedList[myList.length*2];
for(int i = 0; i < myList.length*2; i++){
newList[i] = new LinkedList<StringPair>();
}
return newList;
}
/**
* rehash all the elements
*/
private void rehash(){
LinkedList<StringPair>[] newList = expand();
//rehash all the elements
for(int i = 0; i < this.myList.length;i++){
for(int j = 0; j < myList[i].size(); j++){
//get key
String key = myList[i].get(j).getKey();
String origin = myList[i].get(j).getOrigin();//get original word
int newHash = hashValue(key,newList.length);
newList[newHash].add(new StringPair(origin,key));
}
}
this.myList = newList;
}
}
/**
* help method to sort a string
* @param s the string to sort
* @return
*/
private static String sortString(String s){
char[] array = s.toCharArray();
int small;
//selection sort
for (int i = 0; i < array.length; i++) {
small = i;
for (int j = i + 1; j < array.length; ++j) {
//if index at j is smaller than small
//change small to j
if (array[j] < array[small]) {
small = j;
}
}
//swap small and i
char temp = array[i];
array[i] = array[small];
array[small] = temp;
}
String newS = new String(array);
return newS;
}
/**
* main method
* @param args command-line args
*/
public static void main(String[] args){
//if the args length is not two
//invalid input
if(args.length != 2){
System.out.println("Invalid input args");
return;
}
//create a hash table
HashTable dic = new HashTable(997);
File file = new File(args[0]);//create file
try{
Scanner input = new Scanner(file);//create input stream
//store dictionary to hash table
while(input.hasNext()){
String original = input.next();
String key = sortString(original);
dic.insert(original,key);
}
input.close();
}catch(FileNotFoundException ex){}
String toFind = args[1];//get the word to find
String key = sortString(toFind);//calculate key
//get the linked list at given key
LinkedList<StringPair> anagrams = dic.getList(key);
boolean found = false;
//find and print all the anagrams
for(int i = 0; i < anagrams.size();i++){
if(key.equals(anagrams.get(i).getKey())){
found = true;
System.out.println(anagrams.get(i).getOrigin());
}
}
//if not found
if(!found)
System.out.println("No anagram found");
}
}
| [
"[email protected]"
] | |
272def7bfb85c125f6c8605c10410e81f39811f5 | 6ef2b3a71eaa725fbfede2b3675d404fb0e6ae50 | /com/remmylife/gui/BGPanel.java | 1714cfb7f5635b81dcb43b9731ab0bbf8fc82895 | [] | no_license | blueboy09/RememberMylife2 | 1951a4a67347e8c4039548c8269855e17ffd8d0c | f17e5fdccdd64191763a1eb1d3b8b47df2e8b8b4 | refs/heads/master | 2021-01-22T19:30:56.128413 | 2013-11-10T02:15:18 | 2013-11-10T02:15:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 764 | java | package com.remmylife.gui;
import javax.swing.JPanel;
import javax.imageio.ImageIO;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
public class BGPanel extends JPanel
{
Image im = null;
public BGPanel()
{
super();
}
public BGPanel(String filePath)
{
super();
try
{
im = ImageIO.read(new File(filePath));
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
}
public void setBackground(String filePath)
{
try
{
im = ImageIO.read(new File(filePath));
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
this.revalidate();
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawImage(im, 0, 0, getWidth(), getHeight(), null);
}
}
| [
"[email protected]"
] | |
f50138414ddc223f3abdb9f205f761fd0b64b029 | 50d94ccc87eaf168f68478fa974ca45dc42b37a8 | /LocalServer.java | bc02359669c412c8138674e5724c78e9c9f6a291 | [] | no_license | paulorneves/live-server | 4a4e00b07a5b1be9b6b4c6c3d875f87d224dd2d1 | 5ffe687a2a0e7eef14bf1d5086d9281aba828c99 | refs/heads/main | 2023-05-30T03:42:07.864811 | 2021-06-09T14:17:21 | 2021-06-09T14:17:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,991 | java | /*
* LocalServer.java
*
* Live Server implementation using Java + JavaScript
* This is a simple and light weigh implementation of the live server plugin available in VS Code
* The program runs two servers on port 9000 and 9001, one acts as a simple http server while the other
* serves the purpose of a live server
* The liveserver.js is important as it makes sure that page is refreshed when the file is updated
*
* Author: satanic-devil
*
*/
import java.io.*;
import java.net.*;
import java.util.*;
public class LocalServer extends BaseServer{
private final int LISTENING_PORT = 9000;
private final String LIVE_SERVER_SCRIPT = "<script src=\"liveserver.js\"></script>";
private LiveServer liveServer = null;
//Pass an extra argument to see the header details
public static void main(String args[]){
new LocalServer( (args.length>0)?true:false );
}
LocalServer(boolean displayHeaders){
this.displayHeaders = displayHeaders;
lastModified = new HashMap<String, Long>();
serverName = "[ Local Server ]";
liveServer = new LiveServer(lastModified);
start(LISTENING_PORT);
}
protected void exitProcess(){
//Stop the live server
liveServer.stopServer();
}
protected void setResponseBody() throws Exception {
FileInputStream fileInputStream = new FileInputStream( file );
StringBuffer tempResponseBody = new StringBuffer();
while( ( noOfBytes = fileInputStream.read(buffer)) > 0){
tempResponseBody.append( new String(buffer, 0, noOfBytes));
}
if( fileName.indexOf(".html") != -1 ){
int pos = tempResponseBody.indexOf("</body>");
responseBody = tempResponseBody.toString().substring(0, pos) +
LIVE_SERVER_SCRIPT +
tempResponseBody.toString().substring(pos);
} else
responseBody = tempResponseBody.toString();
fileInputStream.close();
//Record the last modified date of the file being served
lastModified.put(fileName, file.lastModified());
}
}
| [
"[email protected]"
] | |
50f99ee5ff660194d1b77967dfad32aee9e7c967 | a36dce4b6042356475ae2e0f05475bd6aed4391b | /2005/julypersistenceEJB/ejbModule/com/hps/july/persistence/EJSCMPDocumentPositionHomeBean.java | 537f59407f99b06d0893e37172505b7dd35017e0 | [] | no_license | ildar66/WSAD_NRI | b21dbee82de5d119b0a507654d269832f19378bb | 2a352f164c513967acf04d5e74f36167e836054f | refs/heads/master | 2020-12-02T23:59:09.795209 | 2017-07-01T09:25:27 | 2017-07-01T09:25:27 | 95,954,234 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 819 | java | package com.hps.july.persistence;
/**
* EJSCMPDocumentPositionHomeBean
*/
public class EJSCMPDocumentPositionHomeBean extends com.hps.july.persistence.EJSCMPDocumentPositionHomeBean_d62861c8 {
/**
* EJSCMPDocumentPositionHomeBean
*/
public EJSCMPDocumentPositionHomeBean() throws java.rmi.RemoteException {
super(); }
/**
* postCreateWrapper
*/
public com.hps.july.persistence.DocumentPosition postCreateWrapper(com.ibm.ejs.container.BeanO beanO, Object ejsKey) throws javax.ejb.CreateException, java.rmi.RemoteException {
return (com.hps.july.persistence.DocumentPosition) super.postCreate(beanO, ejsKey);
}
/**
* afterPostCreateWrapper
*/
public void afterPostCreateWrapper(com.ibm.ejs.container.BeanO beanO, Object ejsKey) throws javax.ejb.CreateException, java.rmi.RemoteException {
}
}
| [
"[email protected]"
] | |
8a2c84966e9bf0925a7f3e55763db88679859438 | 9f1770694fe8cef612817309014dc97cc7f6a0b5 | /catalog/src/main/java/com/ibm/asset/trails/domain/MainframeProductInfo.java | 4930b2326355926db76fb7d7b9b50660b098f52e | [] | no_license | upself/trails | 41cfdd27fb22eba99d1425cdce6fe10f5c34cd51 | fcd4c62a8ffde8c60006bce7f1716f5694ee4e19 | refs/heads/master | 2021-04-30T16:49:00.321511 | 2016-09-14T08:32:37 | 2016-09-14T08:32:37 | 80,106,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,788 | java | /**
*
*/
package com.ibm.asset.trails.domain;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
/**
* @author zhangyi
*
*/
@Entity
@Table(name = "PRODUCT_INFO")
public class MainframeProductInfo implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7673013153360069518L;
@Id
@GeneratedValue(generator = "mfGenerator")
@GenericGenerator(name = "mfGenerator", strategy = "foreign", parameters = @Parameter(name = "property", value = "softwerItem"))
protected Long id;
@OneToOne(optional = true)
@PrimaryKeyJoinColumn
private SoftwareItem softwerItem;
@Basic
@Column(name = "SOFTWARE_CATEGORY_ID")
protected Long softwareCategoryId;
@Basic
@Column(name = "PRIORITY")
protected Integer priority;
@Basic
@Column(name = "LICENSABLE")
protected boolean licensable;
@Basic
@Column(name = "CHANGE_JUSTIFICATION")
protected String changeJustification;
@Basic
@Column(name = "REMOTE_USER")
protected String remoteUser;
@Basic
@Column(name = "RECORD_TIME")
protected Date recordTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getSoftwareCategoryId() {
return softwareCategoryId;
}
public void setSoftwareCategoryId(Long softwareCategoryId) {
this.softwareCategoryId = softwareCategoryId;
}
public Integer getPriority() {
return priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
public boolean isLicensable() {
return licensable;
}
public void setLicensable(boolean licensable) {
this.licensable = licensable;
}
public String getChangeJustification() {
return changeJustification;
}
public void setChangeJustification(String changeJustification) {
this.changeJustification = changeJustification;
}
public String getRemoteUser() {
return remoteUser;
}
public void setRemoteUser(String remoteUser) {
this.remoteUser = remoteUser;
}
public Date getRecordTime() {
return recordTime;
}
public void setRecordTime(Date recordTime) {
this.recordTime = recordTime;
}
public SoftwareItem getSoftwerItem() {
return softwerItem;
}
public void setSoftwerItem(SoftwareItem softwerItem) {
this.softwerItem = softwerItem;
}
}
| [
"[email protected]"
] | |
21b439954fb5bf24512ce4ac7c0a390a77abdece | 0429a32a245d974e1b3c89b680d743890ca5e1b7 | /src/main/java/cn/wishhust/muxin/MuxinApplication.java | b9d94229c756cde1554bab280c6b16fd996d8d9c | [] | no_license | pallcard/muxin-api | 5b192b9dc3cca7f821063f591cf49ffcb0c7c9a1 | 95cd03740327ddaffb2f57ea041021b1b4e8c809 | refs/heads/master | 2022-07-07T12:21:24.879409 | 2019-11-07T01:57:50 | 2019-11-07T01:57:50 | 191,079,522 | 0 | 0 | null | 2020-07-01T23:23:26 | 2019-06-10T02:04:00 | Java | UTF-8 | Java | false | false | 810 | java | package cn.wishhust.muxin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import tk.mybatis.spring.annotation.MapperScan;
@SpringBootApplication
//扫描mybatis mapper包路径
@MapperScan(basePackages = "cn.wishhust.muxin.mapper")
// 扫描 所有需要的包, 包含一些自用的工具类包 所在的路径
@ComponentScan(basePackages = {"cn.wishhust.muxin","org.n3r.idworker"})
public class MuxinApplication {
@Bean
public SpringUtil getSpringUtil() {
return new SpringUtil();
}
public static void main(String[] args) {
SpringApplication.run(MuxinApplication.class, args);
}
}
| [
"[email protected]"
] | |
f38a29ece67bcdaac8b3687e74ec24911013fdd7 | 46680bdcdebacad05adfc9ddc67d58203b3c2a61 | /src/main/java/org/docksidestage/dockside/dbflute/bsentity/dbmeta/SummaryWithdrawalDbm.java | 8dc47b75bf8a8c1936050dad147ca9b7ff6dfc3d | [
"Apache-2.0"
] | permissive | h-funaki/dbflute-test-active-dockside | 782a6338d72a45176775ad48a8f99b5fdaf4ceaf | 3ddb2a220b357241fb8e14a00e380b5b395b11e4 | refs/heads/master | 2021-08-09T02:59:09.313296 | 2017-11-12T01:38:56 | 2017-11-12T01:38:56 | 109,468,284 | 0 | 0 | null | 2017-11-04T04:59:42 | 2017-11-04T04:59:42 | null | UTF-8 | Java | false | false | 14,356 | java | /*
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.docksidestage.dockside.dbflute.bsentity.dbmeta;
import java.util.List;
import java.util.Map;
import org.dbflute.Entity;
import org.dbflute.dbmeta.AbstractDBMeta;
import org.dbflute.dbmeta.info.*;
import org.dbflute.dbmeta.name.*;
import org.dbflute.dbmeta.property.PropertyGateway;
import org.dbflute.dbway.DBDef;
import org.docksidestage.dockside.dbflute.allcommon.*;
import org.docksidestage.dockside.dbflute.exentity.*;
/**
* The DB meta of SUMMARY_WITHDRAWAL. (Singleton)
* @author DBFlute(AutoGenerator)
*/
public class SummaryWithdrawalDbm extends AbstractDBMeta {
// ===================================================================================
// Singleton
// =========
private static final SummaryWithdrawalDbm _instance = new SummaryWithdrawalDbm();
private SummaryWithdrawalDbm() {}
public static SummaryWithdrawalDbm getInstance() { return _instance; }
// ===================================================================================
// Current DBDef
// =============
public String getProjectName() { return DBCurrent.getInstance().projectName(); }
public String getProjectPrefix() { return DBCurrent.getInstance().projectPrefix(); }
public String getGenerationGapBasePrefix() { return DBCurrent.getInstance().generationGapBasePrefix(); }
public DBDef getCurrentDBDef() { return DBCurrent.getInstance().currentDBDef(); }
// ===================================================================================
// Property Gateway
// ================
// -----------------------------------------------------
// Column Property
// ---------------
protected final Map<String, PropertyGateway> _epgMap = newHashMap();
{ xsetupEpg(); }
protected void xsetupEpg() {
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getMemberId(), (et, vl) -> ((SummaryWithdrawal)et).setMemberId(cti(vl)), "memberId");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getMemberName(), (et, vl) -> ((SummaryWithdrawal)et).setMemberName((String)vl), "memberName");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getWithdrawalReasonCode(), (et, vl) -> ((SummaryWithdrawal)et).setWithdrawalReasonCode((String)vl), "withdrawalReasonCode");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getWithdrawalReasonText(), (et, vl) -> ((SummaryWithdrawal)et).setWithdrawalReasonText((String)vl), "withdrawalReasonText");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getWithdrawalReasonInputText(), (et, vl) -> ((SummaryWithdrawal)et).setWithdrawalReasonInputText((String)vl), "withdrawalReasonInputText");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getWithdrawalDatetime(), (et, vl) -> ((SummaryWithdrawal)et).setWithdrawalDatetime(ctldt(vl)), "withdrawalDatetime");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getMemberStatusCode(), (et, vl) -> ((SummaryWithdrawal)et).setMemberStatusCode((String)vl), "memberStatusCode");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getMemberStatusName(), (et, vl) -> ((SummaryWithdrawal)et).setMemberStatusName((String)vl), "memberStatusName");
setupEpg(_epgMap, et -> ((SummaryWithdrawal)et).getMaxPurchasePrice(), (et, vl) -> ((SummaryWithdrawal)et).setMaxPurchasePrice(cti(vl)), "maxPurchasePrice");
}
public PropertyGateway findPropertyGateway(String prop)
{ return doFindEpg(_epgMap, prop); }
// ===================================================================================
// Table Info
// ==========
protected final String _tableDbName = "SUMMARY_WITHDRAWAL";
protected final String _tableDispName = "SUMMARY_WITHDRAWAL";
protected final String _tablePropertyName = "summaryWithdrawal";
protected final TableSqlName _tableSqlName = new TableSqlName("SUMMARY_WITHDRAWAL", _tableDbName);
{ _tableSqlName.xacceptFilter(DBFluteConfig.getInstance().getTableSqlNameFilter()); }
public String getTableDbName() { return _tableDbName; }
public String getTableDispName() { return _tableDispName; }
public String getTablePropertyName() { return _tablePropertyName; }
public TableSqlName getTableSqlName() { return _tableSqlName; }
// ===================================================================================
// Column Info
// ===========
protected final ColumnInfo _columnMemberId = cci("MEMBER_ID", "MEMBER_ID", null, null, Integer.class, "memberId", null, false, false, false, "INTEGER", 10, 0, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnMemberName = cci("MEMBER_NAME", "MEMBER_NAME", null, null, String.class, "memberName", null, false, false, false, "VARCHAR", 200, 0, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnWithdrawalReasonCode = cci("WITHDRAWAL_REASON_CODE", "WITHDRAWAL_REASON_CODE", null, null, String.class, "withdrawalReasonCode", null, false, false, false, "CHAR", 3, 0, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnWithdrawalReasonText = cci("WITHDRAWAL_REASON_TEXT", "WITHDRAWAL_REASON_TEXT", null, null, String.class, "withdrawalReasonText", null, false, false, false, "CLOB", 2147483647, 0, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnWithdrawalReasonInputText = cci("WITHDRAWAL_REASON_INPUT_TEXT", "WITHDRAWAL_REASON_INPUT_TEXT", null, null, String.class, "withdrawalReasonInputText", null, false, false, false, "CLOB", 2147483647, 0, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnWithdrawalDatetime = cci("WITHDRAWAL_DATETIME", "WITHDRAWAL_DATETIME", null, null, java.time.LocalDateTime.class, "withdrawalDatetime", null, false, false, false, "TIMESTAMP", 23, 10, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnMemberStatusCode = cci("MEMBER_STATUS_CODE", "MEMBER_STATUS_CODE", null, null, String.class, "memberStatusCode", null, false, false, false, "CHAR", 3, 0, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnMemberStatusName = cci("MEMBER_STATUS_NAME", "MEMBER_STATUS_NAME", null, null, String.class, "memberStatusName", null, false, false, false, "VARCHAR", 50, 0, null, null, false, null, null, null, null, null, false);
protected final ColumnInfo _columnMaxPurchasePrice = cci("MAX_PURCHASE_PRICE", "MAX_PURCHASE_PRICE", null, null, Integer.class, "maxPurchasePrice", null, false, false, false, "INTEGER", 10, 0, null, null, false, null, null, null, null, null, false);
/**
* MEMBER_ID: {INTEGER(10)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnMemberId() { return _columnMemberId; }
/**
* MEMBER_NAME: {VARCHAR(200)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnMemberName() { return _columnMemberName; }
/**
* WITHDRAWAL_REASON_CODE: {CHAR(3)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnWithdrawalReasonCode() { return _columnWithdrawalReasonCode; }
/**
* WITHDRAWAL_REASON_TEXT: {CLOB(2147483647)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnWithdrawalReasonText() { return _columnWithdrawalReasonText; }
/**
* WITHDRAWAL_REASON_INPUT_TEXT: {CLOB(2147483647)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnWithdrawalReasonInputText() { return _columnWithdrawalReasonInputText; }
/**
* WITHDRAWAL_DATETIME: {TIMESTAMP(23, 10)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnWithdrawalDatetime() { return _columnWithdrawalDatetime; }
/**
* MEMBER_STATUS_CODE: {CHAR(3)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnMemberStatusCode() { return _columnMemberStatusCode; }
/**
* MEMBER_STATUS_NAME: {VARCHAR(50)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnMemberStatusName() { return _columnMemberStatusName; }
/**
* MAX_PURCHASE_PRICE: {INTEGER(10)}
* @return The information object of specified column. (NotNull)
*/
public ColumnInfo columnMaxPurchasePrice() { return _columnMaxPurchasePrice; }
protected List<ColumnInfo> ccil() {
List<ColumnInfo> ls = newArrayList();
ls.add(columnMemberId());
ls.add(columnMemberName());
ls.add(columnWithdrawalReasonCode());
ls.add(columnWithdrawalReasonText());
ls.add(columnWithdrawalReasonInputText());
ls.add(columnWithdrawalDatetime());
ls.add(columnMemberStatusCode());
ls.add(columnMemberStatusName());
ls.add(columnMaxPurchasePrice());
return ls;
}
{ initializeInformationResource(); }
// ===================================================================================
// Unique Info
// ===========
// -----------------------------------------------------
// Primary Element
// ---------------
protected UniqueInfo cpui() {
throw new UnsupportedOperationException("The table does not have primary key: " + getTableDbName());
}
public boolean hasPrimaryKey() { return false; }
public boolean hasCompoundPrimaryKey() { return false; }
// ===================================================================================
// Relation Info
// =============
// cannot cache because it uses related DB meta instance while booting
// (instead, cached by super's collection)
// -----------------------------------------------------
// Foreign Property
// ----------------
// -----------------------------------------------------
// Referrer Property
// -----------------
// ===================================================================================
// Various Info
// ============
// ===================================================================================
// Type Name
// =========
public String getEntityTypeName() { return "org.docksidestage.dockside.dbflute.exentity.SummaryWithdrawal"; }
public String getConditionBeanTypeName() { return "org.docksidestage.dockside.dbflute.cbean.SummaryWithdrawalCB"; }
public String getBehaviorTypeName() { return "org.docksidestage.dockside.dbflute.exbhv.SummaryWithdrawalBhv"; }
// ===================================================================================
// Object Type
// ===========
public Class<SummaryWithdrawal> getEntityType() { return SummaryWithdrawal.class; }
// ===================================================================================
// Object Instance
// ===============
public SummaryWithdrawal newEntity() { return new SummaryWithdrawal(); }
// ===================================================================================
// Map Communication
// =================
public void acceptPrimaryKeyMap(Entity et, Map<String, ? extends Object> mp)
{ doAcceptPrimaryKeyMap((SummaryWithdrawal)et, mp); }
public void acceptAllColumnMap(Entity et, Map<String, ? extends Object> mp)
{ doAcceptAllColumnMap((SummaryWithdrawal)et, mp); }
public Map<String, Object> extractPrimaryKeyMap(Entity et) { return doExtractPrimaryKeyMap(et); }
public Map<String, Object> extractAllColumnMap(Entity et) { return doExtractAllColumnMap(et); }
}
| [
"[email protected]"
] | |
974a3128993dab72ca88760b3cc8e712f752a9be | f5659415c94e82ba5b84f9f2d4a11e23a98bc4ec | /src/init/Logout.java | 93e96098721506138268496b109100aaba9be912 | [] | no_license | jadyms/S4CA_2017255 | 290ca6c6ab28c2299cc69e473f7fc1704abbe1a0 | 06bc80552cad813e4f7f78710b08716ba101f140 | refs/heads/master | 2020-05-04T13:16:05.174308 | 2019-05-12T22:38:23 | 2019-05-12T22:38:23 | 179,153,605 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,078 | java | package init;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class Logout extends JFrame implements ActionListener{
/*
Class to be called when logout is hit
Displays a JOptionPane with Yes or No option
*/
//Constructor
public Logout() {
}
//Return 0 if user choose to logout and 1 if user hits No
public int logout() {
//yes = 0 //no = 1
int r = JOptionPane.showConfirmDialog(null,
"Would you like to logout?",
"Logout",
JOptionPane.YES_NO_OPTION);
return r;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Logout")) {
int r = logout();
//Would you like to logout? YES
if (r == 0) {
System.exit(r);
} else if (r == 1) {
//DO NOTHINHG, JUST CLOSE THE DIALOG BOX
}
}
}
}
| [
"[email protected]"
] | |
04b3e5beef979caec6ace718b78a7c79f7142fe7 | 6dc07a137c6b88ed6e6756964281a376a8fd6336 | /spring-boot-mq-rabbitmq/src/test/java/cn/liangyy/mq/rabbitmq/RabbitmqdemoApplicationTests.java | 1cacaf600334987edd89d08ec6c880785952272d | [] | no_license | LiangSir-67/spring-boot-group | 8c2fd8d5d5fbf72a332ebcce74d4b0cb3cc30820 | 1694f4129e8cc1c874d6a0201086a02387c39cb1 | refs/heads/master | 2023-04-04T12:58:39.506913 | 2021-04-13T02:23:59 | 2021-04-13T02:23:59 | 356,175,464 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,932 | java | package cn.liangyy.mq.rabbitmq;
import cn.liangyy.mq.rabbitmq.constants.RabbitConsts;
import cn.liangyy.mq.rabbitmq.message.MessageStruct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 测试类
*
* @Author: 梁歪歪 <[email protected]>
* @Description: blog <liangyy.cn>
* @Create 2021-04-09-11:16
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class RabbitmqdemoApplicationTests {
@Autowired
private RabbitTemplate rabbitTemplate;
/**
* 测试直接模式发送
*/
@Test
public void sendDirect(){
rabbitTemplate.convertAndSend(RabbitConsts.DIRECT_MODE_QUEUE_ONE,new MessageStruct("direct message..."));
}
/**
* 测试分列模式发送
*/
@Test
public void sendFanout() {
rabbitTemplate.convertAndSend(RabbitConsts.FANOUT_MODE_QUEUE, "", new MessageStruct("fanout message..."));
}
/**
* 测试主题模式发送1
*/
@Test
public void sendTopic1() {
rabbitTemplate.convertAndSend(RabbitConsts.TOPIC_MODE_QUEUE, "queue.aaa.bbb", new MessageStruct("topic message..."));
}
/**
* 测试主题模式发送2
*/
@Test
public void sendTopic2() {
rabbitTemplate.convertAndSend(RabbitConsts.TOPIC_MODE_QUEUE, "ccc.queue", new MessageStruct("topic message..."));
}
/**
* 测试主题模式发送3
*/
@Test
public void sendTopic3() {
rabbitTemplate.convertAndSend(RabbitConsts.TOPIC_MODE_QUEUE, "3.queue", new MessageStruct("topic message..."));
}
}
| [
"[email protected]"
] | |
8d7aea703730920c9c078b40e4a12996ceacd2e5 | badc7eedced84b87cc0d14c95f1eda90956a3286 | /toolsappserver/src/main/java/com/toolsapp/web/GunController.java | 775039d8d3f8a96b0b5842456916c0e5984e9755 | [] | no_license | jonathanlam77/SpringBootSqlBootstrapToolsApp | 0f2e6edb0cfadeda720b7f0e6e5bd8fbc780cd64 | 5a051970d4bdd685f4495b4366ea93eea2fd457f | refs/heads/master | 2021-04-09T15:17:24.487840 | 2018-03-19T04:45:19 | 2018-03-19T04:45:19 | 125,801,968 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,248 | java | package com.toolsapp.web;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.toolsapp.model.Gun;
import com.toolsapp.service.ToolService;
@Controller
@RequestMapping(path="/tool/gun")
public class GunController extends BaseController {
@Autowired
ToolService service;
@ResponseBody
@RequestMapping(value = "/", method = RequestMethod.POST)
public ResponseEntity<Gun> add (
@RequestParam(required = true, value = "data") final String data
) throws JsonParseException, JsonMappingException, IOException {
Gun s =s_mapper.readValue(data, Gun.class);
s = (Gun)service.add(s);
return new ResponseEntity<Gun>(s, HttpStatus.CREATED);
}
}
| [
"[email protected]"
] | |
a785b16ddfc423494e5fe5b61faf8d5db2c08c97 | 1114b6fe5b6fab1875e511806f6f9f9aa579fac9 | /src/main/java/org/golchin/ontology_visualization/GraphExportToImageService.java | e658058805f664494822c5876f8988dbe9625066 | [] | no_license | romagolchin/ontology-visualization | 4f889c9681014e6e62d58579e4ee4fe8ab5a9777 | 2678cfe80c271ba158d0e4c3ddf3ae6f44b3516a | refs/heads/master | 2023-05-14T21:41:28.067341 | 2021-06-08T09:50:40 | 2021-06-08T09:50:40 | 294,519,602 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 491 | java | package org.golchin.ontology_visualization;
import org.graphstream.stream.file.FileSink;
import org.graphstream.stream.file.FileSinkImages;
import org.graphstream.ui.javafx.util.FxFileSinkImages;
public class GraphExportToImageService extends FileSinkGraphExportService {
@Override
protected FileSink createSink() {
FileSinkImages fileSink = new FxFileSinkImages();
fileSink.setLayoutPolicy(FileSinkImages.LayoutPolicy.NO_LAYOUT);
return fileSink;
}
}
| [
"[email protected]"
] | |
1861833b169b048f337f51c6a54c9c5182544ce9 | be932cae69ad9e9d28950e1c6540872686cdabf9 | /rongke-common/src/main/java/com/rongke/commons/FailException.java | 55770e7ce95e5d99dc32cfac17e6576701003ffa | [] | no_license | gaolizhan/rongke | a8af53f7810d462c8294c248c89faf8a6ae10daa | 684a1aa522f182137b3b23b0ec98e2fbd4eef801 | refs/heads/master | 2020-04-08T08:18:49.829102 | 2018-11-25T14:53:35 | 2018-11-25T14:53:35 | 159,174,206 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 891 | java | package com.rongke.commons;
/**
* 失败异常
* Created by bin on 2017/2/20.
*/
public class FailException extends JsonException {
private static final long serialVersionUID = 1L;
public FailException() {
super();
setJsonResp(new JsonResp().failRes());
}
public FailException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
setJsonResp(new JsonResp().failRes(message));
}
public FailException(String message, Throwable cause) {
super(message, cause);
setJsonResp(new JsonResp().failRes(message));
}
public FailException(String message) {
super(message);
setJsonResp(new JsonResp().failRes(message));
}
public FailException(Throwable cause) {
super(cause);
}
}
| [
"[email protected]"
] | |
ceaa0b6831be0d06d6ceed743c8bd4cbe8a962e4 | 136f25eb4017de48328101b99e7c61536fd773e8 | /app/src/main/java/com/konkuk/dna/friend/manage/Request.java | a19113f9769a32c7a72971e79bb95d1770b14249 | [] | no_license | idjoopal/DNA_Android | dc5d5e7ef97103ddd0a94b4ea382afe740fbb57f | 39b6000553bb9e7478d8decb409167336de486a8 | refs/heads/master | 2020-04-09T06:53:07.012345 | 2018-12-03T04:00:38 | 2018-12-03T04:00:38 | 160,131,305 | 1 | 0 | null | 2018-12-03T04:10:41 | 2018-12-03T04:10:41 | null | UTF-8 | Java | false | false | 875 | java | package com.konkuk.dna.friend.manage;
public class Request {
int idx;
String nickname;
String avatar;
String date;
public int getIdx() {
return idx;
}
public void setIdx(int idx) {
this.idx = idx;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public Request(int idx, String nickname, String avatar, String date) {
this.idx = idx;
this.nickname = nickname;
this.avatar = avatar;
this.date = date;
}
}
| [
"[email protected]"
] | |
016e7fa8f76469926ab78ef1b85c98511c1e5e32 | 2c0f69116c82b53c878cb3a0b5542861a9e8b2ea | /common-components/encryption/src/main/java/org/alfresco/util/encryption/CannotDecryptException.java | 62ef270e6b24ed41dd70e7a56a2f03ff92d20edf | [
"Apache-2.0"
] | permissive | asksasasa83/alfresco-jive-toolkit | 45c1f7c88bb9028c03e80f5936705bfa43c4eb5b | 9267af9608bbab89532fad9755b39adf16fc91fb | refs/heads/master | 2021-05-28T13:53:01.898270 | 2015-03-21T13:18:25 | 2015-03-21T13:18:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,312 | java | /*
* Copyright 2011-2012 Alfresco Software Limited.
*
* 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.
*
* This file is part of an unsupported extension to Alfresco.
*/
package org.alfresco.util.encryption;
/**
* This exception is used to signal that decryption of some encrypted text failed.
*
* @author Peter Monks ([email protected])
* @version $Id: CannotDecryptException.java 41626 2012-09-14 23:59:00Z wabson $
*
*/
public class CannotDecryptException
extends RuntimeException
{
private static final long serialVersionUID = 5861663023997730443L;
public CannotDecryptException(final String message)
{
super(message);
}
public CannotDecryptException(final String message, final Throwable cause)
{
super(message, cause);
}
}
| [
"[email protected]"
] | |
f746c1051d0b58caee5e87aef47a8cb171260e6e | 1849025a33ab00f5a9881d75aa9f75586e091240 | /code/Rank/src/org/hq/rank/core/RankException.java | 6f2bb1332eb18fce1b3ac9f2a3df6cd28dc11999 | [] | no_license | penghongya11/hqrank | 341a3b585ea3fb91528592a97397df58f4ecac48 | 8d226153d8ba324efd044d9d266ee4f8cf3cb211 | refs/heads/master | 2020-06-02T02:02:48.251403 | 2018-12-13T07:23:25 | 2018-12-13T07:23:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 275 | java | package org.hq.rank.core;
public class RankException extends RuntimeException{
private static final long serialVersionUID = 1L;
public RankException(String args){
super("RankException:"+args);
}
public RankException(){
super("RankService 内部错误");
}
}
| [
"zhen"
] | zhen |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.